javascript - 删除数组中的空元素 remove blank element

访问量: 1099

参考:https://stackoverflow.com/questions/281264/remove-empty-elements-from-an-array-in-javascript

array.filter( x => x )

By using arr.filter(x => x), JS will check whether x is truthy or falsy, i.e. if (x), therefore only the truthy value will be assigned to the new list

订阅/RSS Feed

Subscribe