Object.definePropertiesbeginner// Define multiple property descriptors at once
const obj = {}
Object.defineProperties(obj, {
x: { value: 1, writable: true, enumerable: true },
y: { value: 2, writable: false, enumerable: true },
})Use Object.defineProperties() to define multiple properties with fine-grained descriptors in a single call.
Object.defineProperties(obj, props) lets you define multiple properties in a single call, each with its own descriptor.
Challenge: Implement addMultiple(obj) that defines x (value: 1) and y (value: 2) on obj using Object.defineProperties.
const o = {}
addMultiple(o)
o.x // β 1
o.y // β 2