What is delete operator in javascript

What is delete operator :



delete operator:

The delete operator removes a property from an object.

Syntax of delete operator:

delete <expression >

where expression should evaluate to a property reference, e.g.

The delete operator use to remove the property of object.

delete object['property']

Parameters of delete operator:


  • object:The name of an object, or an expression evaluating to an object.
  • property:The property to delete.
  • Returns:Throws in strict mode if the property is an own non-configurable property (returns false in non-strict). Returns true in all other cases.



Description of delete operator :

Unlike what common belief suggests, the delete operator has nothing to do with directly freeing memory (it only does indirectly via breaking references. See the memory management page for more details).

If the delete operator succeeds, it removes the property from the object entirely. However, if a property with the same name exists on the object's prototype chain, the object will inherit that property from the prototype.

delete is only effective on an object's properties. It has no effect on variable or function names.

While sometimes mis-characterized as global variables, assignments that don't specify an object (e.g. x = 5) are actually property assignments on the global object.


Comments

Post a Comment

Popular posts from this blog