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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -