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.
A data descriptor defines both value and writable. This exercises combining multiple property options in one call.
Challenge: Implement setupCounter(obj) that uses Object.defineProperties to add a count property (value: 0, writable: true) and a step property (value: 1, writable: false).
const o = {}
setupCounter(o)
o.count += o.step // β 1