js过滤数组中出现的null

#js过滤数组中出现的null

let arr = [1,2,3,null,5]
let arr1 = arr.filter(n => n)
console.log(arr1)
arr1[1,2,3,,5]

你可能感兴趣的:(js)