1var person = {"first_name": "Billy","last_name": "Johnson"};
2delete person.last_name; //delete last_name property
1var myObject = {
2 "name": "jon",
3 "gender": "male",
4 "registered": "yes"
5};
6delete myObject.gender;
7
8console.log(myObject);
9
10//other methods
11delete myObject.gender;
12// or,
13delete myObject['gender'];
14// or,
15var prop = "gender";
16delete myObject[prop];
1 var person = {
2 name: "Harry",
3 age: 16,
4 gender: "Male"
5 };
6
7 // Deleting a property completely
8 delete person.age;
9 alert(person.age); // Outputs: undefined
10 console.log(person); // Prints: {name: "Harry", gender: "Male"}
1// Creates a new object, myobj, with two properties, a and b.
2var myobj = new Object;
3myobj.a = 5;
4myobj.b = 12;
5
6// Removes the a property, leaving myobj with only the b property.
7delete myobj.a;
8console.log ('a' in myobj); // output: "false"
9