Removing undefined values from Array

后端 未结 13 2018
死守一世寂寞
死守一世寂寞 2020-12-02 16:52

In certain situations, it may happen that we have undefined or generally falsy values in Array structures. For instance when reading and filling data f

13条回答
  •  [愿得一人]
    2020-12-02 17:19

    As Diogo Capela said, but where 0 is not filtered out as well.

    [].filter(item => item !== undefined && item !== null)
    

提交回复
热议问题