UNB/ CS/ David Bremner/ teaching/ cs2613/ books/ mdn/ Reference/ Global Objects/ Object/ Object.defineProperties()

The Object.defineProperties() static method defines new or modifies existing properties directly on an object, returning the object.

Syntax

Object.defineProperties(obj, props)

Parameters

Return value

The object that was passed to the function.

Examples

Using Object.defineProperties

const obj = {};
Object.defineProperties(obj, {
  property1: {
    value: true,
    writable: true,
  },
  property2: {
    value: "Hello",
    writable: false,
  },
  // etc. etc.
});

Specifications

Browser compatibility

See also