1Object.keys(obj).forEach(key => obj[key] === undefined && delete obj[key])
1const obj = {
2 a: 1,
3 b: undefined
4}
5
6// pure functional approach without side-effects
7const newObject = Object.keys(obj).reduce((acc, key) => {
8 const _acc = acc;
9 if (obj[key] !== undefined) _acc[key] = obj[key];
10 return _acc;
11}, {})
12
13console.log(newObject)
14// Object {a: 1}