Created
January 11, 2016 14:20
-
-
Save fauverism/232863edc68a889d962c to your computer and use it in GitHub Desktop.
Creates an array with all falsey values removed.
This file contains hidden or 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
_.compact(array) | |
# Ⓢ Ⓝ | |
Creates an array with all falsey values removed. The values false, null, 0, "", undefined, and NaN are falsey. | |
Arguments | |
array (Array): The array to compact. | |
Returns | |
(Array): Returns the new array of filtered values. | |
Example | |
_.compact([0, 1, false, 2, '', 3]); | |
// → [1, 2, 3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment