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];
1function removeProperty(obj, prop) {
2
3 if (obj.hasOwnProperty(prop)) {
4 delete obj[prop];
5 return true;
6 }
7
8 return false;
9}
1function removeProperty(obj, prop) {
2if (obj[prop] != undefined) {
3 delete obj[prop];
4 return true;
5} else {
6 return false;
7}
8return null;
9}