Creates a new array with all falsey values removed.
Falsey values include: false, null, 0, "", undefined, and NaN.
false
null
0
""
undefined
NaN
The array to filter.
A new array with all falsey values removed.
compact([0, 1, false, 2, "", 3]);// → [1, 2, 3] Copy
compact([0, 1, false, 2, "", 3]);// → [1, 2, 3]
1.0.0
Creates a new array with all falsey values removed.
Falsey values include:
false
,null
,0
,""
,undefined
, andNaN
.