使用 filter() 过滤 “空” 值,如 null、undefined 或空字符串,可以使用 .filter(Boolean) 的缩写方法
也可以
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter(word => word.length > 6);
console.log(result);
// expected output: Array ["exuberant", "destruction", "present"]
Array.prototype.filter() - JavaScript | MDN










