JS: Reflect.set

By Xah Lee. Date: . Last updated: .

New in ES2015.

Similar to obj[key] = val.

Add or modify a property. Returns true if success, else false.

receiver todo

var e = {};
Reflect.set ( e , "p", 3 )
console.log(e); // { p: 3 }

Example of failure:

// example of failed attempt to set property
var e = {};
Object.preventExtensions ( e );
var returnValue = Reflect.set ( e , "p", 3 );
console.log(e); // {}
console.log(returnValue); // false

[see JS: Access Property]

back to JS: Reflect

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

  1. HTML
  2. CSS
  3. JavaScript
  4. JS Obj Ref
  5. DOM
  6. SVG
  7. Blog