JS: Reflect.defineProperty
(new in JS: ECMAScript 2015)
Reflect.defineProperty(obj, key, descriptor)
-
Create or modify a property's attributes
by
Property Descriptor.
Returntrue
if successful, elsefalse
.
// example of creating or changing a property attribute const jj = {}; const yy = Reflect.defineProperty(jj, "kk", { value: 3, writable: true, enumerable: false, configurable: true, }); console.log(jj.kk === 3); console.log(jj.propertyIsEnumerable("kk") === false); // return value is true/false console.log(yy === true);