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"}
1var ourDog = {
2 "name": "Camper",
3 "legs": 4,
4 "tails": 1,
5 "friends": ["everything!"],
6 "bark": "bow-wow"
7};
8
9delete ourDog.bark;
1// ES6 should be in search keyword
2Reflect.deleteProperty(myObj, propNameString);
3// Source referece in Chinese.
1var person = {
2 firstName:"John",
3 lastName:"Doe",
4 age:50,
5 eyeColor:"blue"
6};
7
8delete person.age; // or delete person["age"];
9
10// Before deletion: person.age = 50, after deletion, person.age = undefined
11