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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -