Standard built-ins

Object.defineProperties()

Try the free JavaScript compiler

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

NameTypeDescription
objObjectTarget object.
propsObjectMapping 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);
JavaScript Reference