js怎么过滤数组中的false,null,"",undefined,NaN,0

let arr = [1,2,3,null,4,0,undefined,5,NaN,6,7,false]

let newArr = arr.filter(Boolean)

console.log(newArr)
//  [1, 2, 3, 4, 5, 6, 7]

你可能感兴趣的:(js怎么过滤数组中的false,null,"",undefined,NaN,0)