Reflect.deleteProperty
Deletes a property from an object, equivalent to the delete operator but as a function that returns a boolean
Syntax
Reflect.deleteProperty(target, propertyKey)Parameters
| Parameter | Type | Description |
|---|---|---|
| target | object | The target object |
| propertyKey | string | symbol | The name of the property to delete |
Return Value
A boolean indicating whether the property was deleted
Examples
const obj: Record<string, number> = { x: 1, y: 2 }
Reflect.deleteProperty(obj, 'x')
console.log(obj) // { y: 2 }const obj = { a: 1, b: 2, c: 3 }
const deleted = Reflect.deleteProperty(obj, 'b')
console.log(deleted) // true
console.log(obj) // { a: 1, c: 3 }const frozen = Object.freeze({ x: 1 })
console.log(Reflect.deleteProperty(frozen, 'x')) // falseUnderstanding Reflect.deleteProperty
The Reflect.deleteProperty method in JavaScript deletes a property from an object, equivalent to the delete operator but as a function that returns a boolean. It belongs to the Reflect object and is one of the most widely used methods for working with reflect values in modern JavaScript and TypeScript applications.
The method signature is Reflect.deleteProperty(target, propertyKey). It accepts 2 parameters: target, propertyKey. When called, it returns a boolean indicating whether the property was deleted. Understanding when and how to use deleteProperty() helps you write more expressive, readable code.
Common use cases for Reflect.deleteProperty include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like reflect-set, reflect-has, reflect-defineproperty, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Reflect.deleteProperty is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
Reflect.setSets the value of a property on an object, similar to target[propertyKey] = value but as a function
Reflect.hasReturns a boolean indicating whether the target object has the specified property, equivalent to the in operator
Reflect.definePropertyDefines a new property directly on an object or modifies an existing property, returning a boolean indicating success
More Reflect Methods
Other methods in the Reflect object
Related Tools
More Reflect Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.