Operators

delete operator

Try the free JavaScript compiler

Attempts to remove a property. Ordinary configurable own properties can be removed; nonconfigurable ones cannot, and strict-mode failure throws. Deleting a missing own property usually succeeds. Does not delete an inherited property from its prototype.

Formal Syntax & Structure

javascript syntaxjavascript
delete object[key]

Parameters & Attributes

NameTypeDescription
targetproperty referenceProperty to remove.

Return Value

boolean

True for successful deletion; false for some non-strict failures.

Working Example

Example Snippetjavascript
const a={n:1};console.log(delete a.n,"n" in a);
JavaScript Reference