delete item object js code example
Example 1: 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];
Example 2: javascript remove object key
var obj = {a: 5, b: 3};
delete obj["a"];
console.log(obj); // {b: 3}