delete special operatorS2C Home « Operators « delete

Property deletion.


The delete special operator allows us to delete a property of an object.


Signature Description
delete expressionSpecial operator which allows us to delete a property of an object.


Parameter Description
expressionExpression that evaluates to an object reference.
  • Can be a variable name if the variable has been declared as a property of the global object (without var or function statements).
  • An object expression such as or someObject['property'].
  • An array-like object expression such as someObject[indexToDelete].


Will return 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[1] + ' Array now holds: ' + names);  

Press the button below to action the above code:

Related Tutorials

JavaScript Basic Tutorials - Lesson 7 - Objects

go to home page Homepage go to top of page Top