Deleting Properties

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;

No comments:

Post a Comment

Overview of AngularJS

AngularJS is an open source web application framework. It is now maintained by Google . The most of the code can be eliminated by using th...