📅  最后修改于: 2022-03-11 14:48:20.430000             🧑  作者: Mango
const obj = {
a: 1,
b: undefined
}
// pure functional approach without side-effects
const newObject = Object.keys(obj).reduce((acc, key) => {
const _acc = acc;
if (obj[key] !== undefined) _acc[key] = obj[key];
return _acc;
}, {})
console.log(newObject)
// Object {a: 1}