Object.definePropertiesintermediate// 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.
You can mix writable and non-writable properties in a single Object.defineProperties call.
Challenge: Implement addMixed(obj) that adds editable (writable, value: 10) and fixed (non-writable, value: 99) to obj.
const o = {}
addMixed(o)
o.editable = 50 // works
o.fixed = 0 // silently fails
o.editable // β 50
o.fixed // β 99