Object.defineProperties

Adds properties to an object, or modifies attributes of existing properties.

Syntax

defineProperties(object, properties)

Parameters

Return value

The object that was passed to the function.

Examples

let obj = {}
Object.defineProperties(obj, {
  speed: {
    value: 120,
    writable: true
  },
  unit: {
    value: "mph",
    writable: false
  }
});
`${obj.speed} ${obj.unit}`
"120 mph"