/

HTML / CSS / JavaScript Tutorial

JavaScript Operator: delete

[this page | pdf | back links]

In JavaScript, the delete operator deletes a property from an object. For example, suppose:

 

var x = {name: "ten", val: 10, binaryval: "1010"}

 

This creates an object with three name/value pairs.

 

Then delete x.value (or delete x["val"]) would result in x becoming:

 

{name: "ten", binaryval: "1010"}

 

It is usually unwise to apply the delete operator to predefined JavaScript object properties, as otherwise the application can crash.

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript Operators


Desktop view | Switch to Mobile