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

else false.

See also: JS: Delete operator

const obj = {x: 1};
Reflect.deleteProperty ( obj , "x" );
console.log ( obj.hasOwnProperty("x") === false ); // true

Example when key doesn't exist:

const obj = {x: 1};

console.log (
Reflect.deleteProperty ( obj , "y" )
); // true

Example when deleting failed:

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

console.log (
Reflect.deleteProperty ( u , "p" ) === false
); // true

[see JS: Access Property]

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. Property Existence
  7. Access Property
  8. List Properties
  9. Property Attributes
  10. Getter/Setter
  11. Property Descriptor
  12. Symbol
Like it? Help me by telling your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

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

Web Dev Tutorials