CKTIS / JavaScript
Reflect.set — property assignment with a boolean result
Reflect.set performs a property assignment operation and returns a boolean indicating success. Its optional receiver separates the object where property lookup begins from the recipient of the write.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
Reflect.set(target, key, value[, receiver])Reflect.set(target, key, value[, receiver]) invokes the target object's internal [[Set]] operation. The key argument is converted to a property key: a string or symbol. An omitted receiver defaults to target.
The result is true or false, not the assigned value. For ordinary objects, false can indicate an attempt to change a property with writable: false, use an accessor without a setter, or add a property to a non-extensible receiver. A false result alone does not throw even in strict mode, unlike a rejected target[key] = value assignment in that mode.
Descriptor lookup starts at target and can traverse its prototypes. For a writable data property, the write generally creates or updates an own property on receiver, subject to its restrictions. When a setter is called, receiver is passed as the this argument. If the setter is an ordinary JavaScript function in non-strict mode, its this is the global this value for a null or undefined receiver, and other primitive receivers are boxed. The setter's return value is ignored. Consequently, true does not guarantee that a later read will return value.
The method is not an error-catching mechanism: a non-object target causes TypeError, and exceptions from key conversion, a setter, or a Proxy trap propagate. Directly defining an own property does not search the prototype chain or call inherited setters, but it still respects the restrictions of an existing own property descriptor. For example, it cannot change the value of an own data property that is both non-configurable and non-writable.
Examples
"use strict";
const target = { score: 1 };
const receiver = {};
console.log(Reflect.set(target, "score", 7, receiver));
console.log(target.score, receiver.score);
Object.defineProperty(target, "fixed", {
value: 10,
writable: false
});
console.log(Reflect.set(target, "fixed", 20));
console.log(target.fixed);Result
true 1 7 false 10
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.