Export (0) Print
Expand All

delete Operator

Deletes a property from an object, removes an element from an array, or removes an entry from an IDictionary object.

delete expression

expression

Required. Any expression that results in a property reference, array element, or IDictionary object.

If the result of expression is an object, the property specified in expression exists, and the object will not allow it to be deleted, false is returned.

In all other cases, true is returned.

The following example illustrates a use of the delete operator.

// Make an object with city names and an index letter.
var cities : Object = {"a" : "Athens" , "b" : "Belgrade", "c" : "Cairo"}

// List the elements in the object.
var key : String;
for (key in cities) {
   print(key + " is in cities, with value " + cities[key]);
}

print("Deleting property b");
delete cities.b;

// List the remaining elements in the object.
for (key in cities) {
   print(key + " is in cities, with value " + cities[key]);
}

The output of this code is:

a is in cities, with value Athens
b is in cities, with value Belgrade
c is in cities, with value Cairo
Deleting property b
a is in cities, with value Athens
c is in cities, with value Cairo

Community Additions

ADD
Show:
© 2014 Microsoft