Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The delete operator removes a property from an object. If the property's value is an object and there are no more references to the object, the object held by that property is eventually released automatically.
Note: The syntax allows a wider range of expressions following the delete operator, but only the above forms lead to meaningful behaviors.
The name of an object, or an expression evaluating to an object.
propertyThe property to delete.
true for all cases except when the property is an own non-configurable property, in which case false is returned in non-strict mode.
Thrown in strict mode if the property is an own non-configurable property.
ReferenceErrorThrown if object is super.
The delete operator has the same precedence as other unary operators like typeof. Therefore, it accepts any expression formed by higher-precedence operators. However, the following forms lead to early syntax errors in strict mode:
Because classes are automatically in strict mode, and private elements can only be legally referenced in class bodies, this means private elements can never be deleted. While delete identifier may work if identifier refers to a configurable property of the global object, you should avoid this form and prefix it with globalThis instead.
While other expressions are accepted, they don't lead to meaningful behaviors:
The delete operator removes a given property from an object. On successful deletion, it will return true, else false will be returned. Unlike what common belief suggests (perhaps due to other programming languages like delete in C++), the delete operator has nothing to do with directly freeing memory. Memory management is done indirectly via breaking references. See the memory management page for more details.
It is important to consider the following scenarios:
Note: The following example uses non-strict-mode only features, like implicitly creating global variables and deleting identifiers, which are forbidden in strict mode.
In the following example, we delete an own property of an object while a property with the same name is available on the prototype chain:
When you delete an array element, the array length is not affected. This holds even if you delete the last element of the array.
When the delete operator removes an array element, that element is no longer in the array. In the following example, trees[3] is removed with delete.
This creates a sparse array with an empty slot. If you want an array element to exist but have an undefined value, use the undefined value instead of the delete operator. In the following example, trees[3] is assigned the value undefined, but the array element still exists:
If instead, you want to remove an array element by changing the contents of the array, use the splice() method. In the following example, trees[3] is removed from the array completely using splice():
When a property is marked as non-configurable, delete won't have any effect, and will return false. In strict mode, this will raise a TypeError.
var creates non-configurable properties that cannot be deleted with the delete operator:
In strict mode, this would raise an exception.
If a global property is configurable (for example, via direct property assignment), it can be deleted, and subsequent references to them as global variables will produce a ReferenceError.
| ECMAScript® 2027 Language Specification # sec-delete-operator |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 17, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.