📅  最后修改于: 2022-03-11 15:03:00.583000             🧑  作者: 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]