Skip to content

Instantly share code, notes, and snippets.

@dougajmcdonald
Last active March 20, 2019 09:33
Show Gist options
  • Save dougajmcdonald/0909370feb55683cf69704f44e6127d2 to your computer and use it in GitHub Desktop.
Save dougajmcdonald/0909370feb55683cf69704f44e6127d2 to your computer and use it in GitHub Desktop.
Remove null values from es6 array
// NOTE: This removes zero's
var array = [1, 2, null, 3, undefined, 0, 4, false, 5];
var arrayWithoutFalseys = array.filter(obj => obj);
console.log(arrayWithoutFalseys); // [1,2,3,4,5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment