clear the properties of an object in js code example
Example 1: js remove undefined from object
Object.keys(obj).forEach(key => obj[key] === undefined && delete obj[key])
Example 2: javscript remove a property
var myObject = {
"name": "jon",
"gender": "male",
"registered": "yes"
};
delete myObject.gender;
console.log(myObject);
//other methods
delete myObject.gender;
// or,
delete myObject['gender'];
// or,
var prop = "gender";
delete myObject[prop];