Standard built-ins
Object.defineProperties()
Defines multiple own properties from a descriptor mapping. Descriptors are collected and validated before definitions; the whole operation is not guaranteed atomic if a later definition fails.
Formal Syntax & Structure
javascript syntaxjavascript
Object.defineProperties(obj, props)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| obj | Object | Target object. |
| props | Object | Mapping of keys to property descriptors. |
Return Value
Object
Same target.
Working Example
Example Snippetjavascript
const o={};Object.defineProperties(o,{a:{value:1},b:{value:2}});console.log(o.a+o.b);