Reflect.deleteProperty(target, propertyKey)removes a property from an object. It is the function version of the delete operator: Reflect.deleteProperty(obj, "a") does the same as delete obj.a.
It returns true when the property is gone after the call, and false when it could not be removed, for example because it is not configurable. It never throws for that, even in strict mode, where the delete operator would.
Remember
Reflect.deleteProperty(target, key)
removed, or was never there → true
cannot be removed → false (no error)
Same as: delete target[key]
target must be an object, or TypeError
Syntax
Pass an object and the name of the property to remove.
JavaScript
const user = { name: "Ann", age: 30 };
console.log(Reflect.deleteProperty(user, "age")); // true
console.log("age" in user); // false
console.log(Reflect.deleteProperty(user, "city")); // true (it was not there)
Call
What it does
Reflect.deleteProperty(obj, "a")
Remove the property a. Returns true if it is gone.
Reflect.deleteProperty(arr, 1)
Remove an array item. It leaves an empty slot and keeps the length.
delete obj.a
The operator. In strict mode it throws a TypeError when removal fails.
// ECMAScript 2015 (ES6)
Reflect.deleteProperty(target, propertyKey)
// target : an object
// propertyKey : a string or a symbol
// returns : true or false
// throws : TypeError if target is not an object
Parameters
Parameter
Description
target
Required. The object to change. If it is not an object, a TypeError is thrown.
propertyKey
Required. The name of the property to remove: a string or a symbol.
Return Value
Return Value
Description
true
The property was removed, or it did not exist in the first place.
false
The property exists but cannot be removed, because it is not configurable (for example on a frozen or sealed object).
TypeError (thrown)
target is not an object.
JavaScript Examples
Example 1 — Remove a Property
Remove a property, remove it again, and remove one that never existed.
Delete age: true
Still has age: false
Delete age again: true
Delete city: true
Keys left: name
How It Works
Remove it. The property age exists and can be removed, so the call returns true and Reflect.has() then says false.
Missing is fine. Deleting age again, or deleting city that was never there, also returns true, because there is nothing left to remove.
Check what remains. Only name is left in the object.
Example 2 — Properties That Cannot Be Removed
A property that is not configurable stays. See the result for a frozen object and for a property made with defineProperty(). The function with "use strict" shows how the operator reacts.
Array items. Removing item 1 leaves an empty slot. The length is still 3, and 1 in letters is false. To close the gap, use splice() instead.
Own properties only.child has no own property called shared, so there is nothing to remove from it, and the call returns true.
The prototype is untouched.child.shared is still readable, because the value comes from parent.
Compatibility
Browser & Runtime Support
Reflect.deleteProperty() is part of ES2015 (ES6), together with the Reflect object. Every current browser and Node.js has it.
✓ ES2015 · Widely supported
Reflect.deleteProperty()
Supported in Chrome 49+, Edge 12+, Firefox 42+, Safari 10+, Opera 36+ and Node.js 6+. Internet Explorer never got it.
ES2015Standard since
Google Chrome49+ · Desktop & Mobile
Full support
Microsoft Edge12+ · Chromium and legacy
Full support
Mozilla Firefox42+ · Desktop & Mobile
Full support
Apple Safari10+ · macOS & iOS
Full support
Opera36+ · Chromium based
Full support
Samsung InternetRecent versions · Android
Supported
Android WebView49+ · Chromium based
Supported
Node.js6+ · Server runtime
Supported
DenoSupported · JavaScript runtime
Supported
BunSupported · JavaScript runtime
Supported
Internet ExplorerNo native support
Not supported
Reflect.deleteProperty()Excellent
Bottom line: Safe to use in every current browser and in Node.js. The only thing to plan for is Internet Explorer, which has no Reflect at all.
Frequently Asked Questions
It removes a property from an object and returns true if the property is gone, or false if it could not be removed. It is the function version of the delete operator.
They remove the same properties. The difference is in strict mode: delete throws a TypeError when the property cannot be removed, while Reflect.deleteProperty() returns false. Also, Reflect.deleteProperty() is a function that you can pass around.
Because the goal is reached: after the call the property is not in the object. true means "it is gone", not "something was removed". Use Reflect.has() first if you need to know.
When the property exists but is not configurable. This is the case for properties of frozen or sealed objects, and for properties created with defineProperty() without configurable: true.
Reflect.deleteProperty(array, index) leaves an empty slot and does not change the length. To remove the item and close the gap, use splice(index, 1) instead.