JS: Reflect.deleteProperty

By Xah Lee. Date: . Last updated: .

New in ES2015.

Reflect.deleteProperty ( obj, key )

Deletes the property key from obj.

Return true if successful, else false.

Similar to delete obj[key]. The delete operator returns true even if key does not exist.

[see JS: Delete operator]

const obj = {x: 1, y: 2};
Reflect.deleteProperty ( obj , "y" );
console.log(obj); // { x: 1 }

If deleting failed, return false.

const u = {p: 1};
Object.freeze ( u );

// if deleting failed, return false
console.log ( Reflect.deleteProperty ( u , "p" ) ); // false

[see JS: Access Property]

Reference

ECMAScript® 2016 Language Specification#sec-reflect.deleteproperty

back to JS: Reflect

JS Object Property Topic

  1. JS: Property Overview
  2. JS: Property Key
  3. JS: Property Dot Notation / Bracket Notation
  4. JS: Create/Delete Property
  5. JS: Get Property, Set Property
  6. JS: Check Property Existence
  7. JS: Access Property
  8. JS: Property Attributes, writable, enumerable, configurable
  9. JS: Getter/Setter Properties
  10. JS: Property Descriptor
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

Patreon me $5. Ask me question on patreon