filter(Boolean)
注意:0也会过滤
const groceries = ['apple', null, 'milk', undefined, 'bread', '',0];
const cleanList = groceries.filter(Boolean);
console.log(cleanList);
// 'apple', 'milk', 'bread';
注意:0也会过滤
const groceries = ['apple', null, 'milk', undefined, 'bread', '',0];
const cleanList = groceries.filter(Boolean);
console.log(cleanList);
// 'apple', 'milk', 'bread';