remove undefined values from object javascript code example
Example 1: js remove undefined from object
Object.keys(obj).forEach(key => obj[key] === undefined && delete obj[key])
Example 2: remove undefined values from object javascript
var obj = { a: 1, b: undefined, c: 3 }
console.log(JSON.parse(JSON.stringify(obj)));
Output: {a: 1, c: 3}