數組的 filter 函數有一個很重要的用處,可以過濾 null、undefined、''
filter
null
undefined
''
var arr = [1, '', null, undefined, ' '] console.log(arr.filter(v => v))