javascript how remove element undefined from any object type code example
Example 1: js remove undefined from object
Object.keys(obj).forEach(key => obj[key] === undefined && delete obj[key])
Example 2: delete object property vs undefined assignment javascript
a.x = undefined
a.hasOwnProperty("x") // returns true
delete a.x
a.hasOwnProperty("x") // returns false