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

  1. Property Overview
  2. Property Key
  3. Dot vs Bracket Notation
  4. Create/Delete Property
  5. Get/Set Property
  6. Check Property Existence
  7. Access Property
  8. List Properties
  9. Property Attributes
  10. Getter/Setter
  11. Property Descriptor
  12. Symbol
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS in Depth
  4. JS Reference
  5. DOM
  6. SVG
  7. Web Dev Blog