A non-inherited property can be removed by using the delete operator.
For Example :
Create a new object, named myObject with two properties :
var myObject = new Object();
myObject.a = 7;
myObject.b = 8;
delete myObject.a;
console.log('a' in myObject) // false (As the object is deleted)
we can also delete a global variable if var keyword is not used to declare a variable.
a = 15;
delete a;
For Example :
Create a new object, named myObject with two properties :
var myObject = new Object();
myObject.a = 7;
myObject.b = 8;
delete myObject.a;
console.log('a' in myObject) // false (As the object is deleted)
we can also delete a global variable if var keyword is not used to declare a variable.
a = 15;
delete a;
No comments:
Post a Comment