Last active
August 29, 2015 14:21
-
-
Save codfish/851cc392f4fffff09605 to your computer and use it in GitHub Desktop.
Quick way to filter/remove non-truthy (null, empty string, number 0, NaN, boolean false) values from an array in Javascript.
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
['false', '', false, true, '0', 0, null, NaN, 1, '1'].filter(Boolean); | |
// => ["false", true, "0", 1, "1"] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment