Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

delete operator

The delete operator removes an object's own property, not the object itself or a variable. Learn its Boolean result, strict-mode restrictions, and the holes it leaves in arrays.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

delete object.property
delete object[key]

delete is a unary operator and a JavaScript reserved word. delete object.property or delete object[key] removes an object's own property; it is not a command for freeing memory or removing a variable.

For ordinary objects, it returns true when the property was removed or was not an own property. A property with configurable: false produces false outside strict mode and throws TypeError in strict mode. Inherited properties remain untouched; deleting an own property can expose a prototype value.

Direct delete name is a SyntaxError in strict mode. Do not use delete to remove let, const, or var bindings. Deleting private fields is also a syntax error.

delete values[1] leaves a hole: it neither shifts elements nor reduces length. This differs from assigning undefined, which preserves the indexed property. The example demonstrates property removal and an array hole.

Examples

"use strict";
const item = { name: "pen" };
console.log(delete item.name);
console.log("name" in item);
console.log(delete item.missing);

const values = [10, 20, 30];
console.log(delete values[1]);
console.log(values.length);
console.log(1 in values);

Result

true
false
true
true
3
false

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources