Last active
March 20, 2019 09:33
-
-
Save dougajmcdonald/0909370feb55683cf69704f44e6127d2 to your computer and use it in GitHub Desktop.
Remove null values from es6 array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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