delete special operatorS2C Home « Operators «
delete special operator allows us to delete a property of an object.
|Special operator which allows us to delete a property of an object.|
|Expression that evaluates to an object reference.|
false only when a property exists and cannot be deleted. Will return
true in all other situations, even when the property doesn't exist.
Following are examples of the
delete special operator.
// The delete operator. var aVariable = 5; // Cannot delete aVariable as created using var statement ( returns false) alert(delete aVariable); bVariable = 5; alert(delete bVariable); // Will be deleted ( returns true) var names = ['fred', 'ned', 'ted', 'jed' ]; alert(delete names + ' Array now holds: ' + names);