array.filter(Boolean)
Array.prototype.filter()方法用于过滤数组,返回一个符合特定操作的元素组成的数组。
array.filter((item) => {return Boolean(item)})
也就是说这样写的意思就是去除数组中为“假”的元素。
微信扫一扫
array.filter(Boolean)
Array.prototype.filter()方法用于过滤数组,返回一个符合特定操作的元素组成的数组。
array.filter((item) => {return Boolean(item)})
也就是说这样写的意思就是去除数组中为“假”的元素。
相关推荐