Skip to content

Instantly share code, notes, and snippets.

@kimili
Created September 19, 2018 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimili/40e8931fb66774d79fa21193630c49e1 to your computer and use it in GitHub Desktop.
Save kimili/40e8931fb66774d79fa21193630c49e1 to your computer and use it in GitHub Desktop.
JavaScript Compact
const compact = arr => arr.filter(Boolean);
compact([1, false, 2, '', 3, null, 'abc']); // [1, 2, 3, 'abc']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment