TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
delete operator is a unary operator that removes a specific own property from an object. Upon successful execution, the property is entirely detached from the object, and subsequent accesses to that property identifier will evaluate to undefined.
Syntax
Return Value
The operator evaluates to aboolean.
- Returns
trueif the property was successfully deleted, or if the property did not exist on the object in the first place. - Returns
falsein JavaScript’s runtime non-strict mode (or throws aTypeErrorin JavaScript’s runtime strict mode via"use strict") if the property is non-configurable, such as properties defined viaObject.defineProperty()withconfigurable: false.
TypeScript Type Checking
TypeScript enforces strict structural typing rules around thedelete operator to prevent runtime mutations that violate an object’s declared contract.
When the strictNullChecks compiler option is enabled (which is included when enabling the broader TypeScript --strict flag), the compiler requires that the operand of a delete operation be an optional property. Attempting to delete a required property results in compiler error TS2790. Furthermore, attempting to delete a property marked as readonly triggers compiler error TS2794, regardless of whether the property is optional or required.
Record<string, any> or {[key: string]: unknown}), which implicitly treats all properties as optional for deletion purposes.
Mechanics and Limitations
- Prototype Chain:
deleteonly operates on an object’s own properties. It does not traverse the prototype chain. If an own property is deleted but a property with the same key exists on the prototype, the prototype’s property will be exposed upon subsequent lookups. - Variables and Functions: The operator cannot delete variables declared with
var,let, orconst, nor can it delete standalone function declarations. It strictly targets object properties. - Arrays: When applied to an array index,
deleteremoves the value at that specific index but does not mutate the array’slengthproperty or shift subsequent elements. This creates a sparse array containing anemptyslot.
Master TypeScript with Deep Grasping Methodology!Learn More





