📅  最后修改于: 2022-03-11 14:48:15.277000             🧑  作者: Mango
// ES6+
const arr = [1, undefined, 2, 3, undefined, 5];
const filteredArr = arr.filter((elem) => elem !== undefined);
console.log(filteredArr); // output: [1, 2, 3, 5]