javascript - How do I keep null and false valued elements in .filter()? -
i'm trying resolve javascript array not number, @ when array holds other falsy elements zero:
[false,null, false, true].filter((x)=>x)
that returns
[true]
but want keep falsy elements. how accomplish that?
then don't rely on falsiness checks, explicitly test numbers.
[false, null, false, true].filter(x => typeof x !== 'number')
Comments
Post a Comment