Back

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

发布时间: 2021-06-14 01:53:00

参考: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

Back