array.filter(Boolean)
Array.prototype.filter()方法用于过滤数组,返回一个符合特定操作的元素组成的数组。
array.filter((item) => {return Boolean(item)})
也就是说这样写的意思就是去除数组中为“假”的元素。
数组去除数组中为“假”的元素。
阅读 63
2021-09-30
array.filter(Boolean)
Array.prototype.filter()方法用于过滤数组,返回一个符合特定操作的元素组成的数组。
array.filter((item) => {return Boolean(item)})
也就是说这样写的意思就是去除数组中为“假”的元素。
相关推荐
精彩评论(0)