Removing undefined values from Array

后端 未结 13 2030
死守一世寂寞
死守一世寂寞 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:21

    If you have an array of objects and want to remove all null and undefined items:

    [].filter(item => !!item);
    

提交回复
热议问题