> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JavaScript Delete

The `delete` operator is a unary operator used to remove an own property from an object. When successful, it severs the binding between the property key and the target object. If no property with the same key exists in the object's prototype chain, subsequent accesses to that key will evaluate to `undefined`; otherwise, the deletion of the own property will expose the inherited property from the prototype.

```javascript theme={"dark"}
delete object.property;
delete object['property'];
```

## Return Value

The operator evaluates to a Boolean value:

* **`true`**: Returned if the property was successfully deleted, or if the property did not exist on the target object.
* **`false`**: Returned in non-strict mode if the property exists but cannot be deleted.

## Technical Mechanics

**1. The `[[Configurable]]` Attribute**
For properties that exist on the target object, the `delete` operator only succeeds if the internal property descriptor attribute `[[Configurable]]` is set to `true`. It will also succeed (return `true`) if the property key does not exist on the object at all. Built-in properties of standard objects (like `Math.PI`) and properties created via `Object.defineProperty()` with `configurable: false` cannot be deleted.

```javascript theme={"dark"}
const obj = {};
Object.defineProperty(obj, 'lockedProp', {
  value: 42,
  configurable: false
});

delete obj.lockedProp; // Returns false (or throws in Strict Mode)
delete obj.nonExistent; // Returns true
console.log(obj.lockedProp); // 42
```

**2. Strict Mode Behavior**
In strict mode (`"use strict";`), attempting to delete a non-configurable property, or attempting to delete an unqualified identifier (e.g., `delete myVar`), throws a `TypeError` or `SyntaxError` instead of silently returning `false`.

**3. Variables and Functions**
The `delete` operator operates exclusively on object properties. It cannot remove bindings from declarative environment records. Therefore, variables declared with `var`, `let`, or `const`, and functions declared via function declarations, cannot be deleted.

```javascript theme={"dark"}
var x = 10;
let y = 20;
function z() {}

delete x; // false (SyntaxError in strict mode)
delete y; // false (SyntaxError in strict mode)
delete z; // false (SyntaxError in strict mode)
```

*Note: Implicit globals (variables assigned without declaration in non-strict mode) are created as configurable properties on the global object and can be deleted.*

**4. Prototype Chain Resolution**
`delete` only mutates the target object directly; it does not traverse the prototype chain. If an object and its prototype share a property key, deleting the own property on the object will expose the inherited property from the prototype.

```javascript theme={"dark"}
function Foo() {}
Foo.prototype.bar = 42;

const instance = new Foo();
instance.bar = 99;

delete instance.bar; // Returns true (deletes own property)
console.log(instance.bar); // 42 (resolves to prototype property)
delete instance.bar; // Returns true (does nothing, property is not on instance)
console.log(instance.bar); // 42 (prototype remains unaffected)
```

**5. Array Mutation**
When applied to an array index, `delete` removes the element but does not update the array's `length` property or shift subsequent elements. This creates a "sparse array" containing an empty slot (a hole).

```javascript theme={"dark"}
const arr = ['a', 'b', 'c'];
delete arr[1]; // Returns true

console.log(arr.length); // 3
console.log(arr); // ['a', empty, 'c']
console.log(arr[1]); // undefined
```

**6. Memory Management**
The `delete` operator does not directly free memory. It only removes the property reference from the object. The underlying value will only be reclaimed by the garbage collector if no other references to that value exist in memory.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor JavaScript Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
