JavaScript: Object.defineProperties
By Xah Lee. Date: . Last updated: .
Object.defineProperties(obj, {key1: descriptor1}, {key2: descriptor2} etc)
-
Create properties or modify existing properties.
Return the modified obj.
The
descriptor1,
descriptor2, etc are Property Descriptor.
const yy = {};
Object.defineProperties(
yy,
{
x1:{ value : 1, writable: true, enumerable: true, configurable: true},
x2:{ value : 2, writable: true, enumerable: true, configurable: true}
}
);
console.log(yy);
JavaScript Define Properties