JavaScript Object.defineProperties() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Object

Definition

Object.defineProperties(obj, props) adds or updates several properties on obj in one call. Each property is described with a descriptor object.

Common descriptor fields for data properties are value, writable, enumerable, and configurable. The method returns the same object.

Syntax

Call Object.defineProperties() like this. Start with this line.

JavaScript
Object.defineProperties(obj, props)
CallWhat it does
Object.defineProperties(obj, props)Defines each property listed in props on obj and returns obj.

Built into JavaScript. Call on Object — no import required.

Library declarations
JavaScript
Object.defineProperties(obj, props)
JavaScript
defineProperties(o: any, properties: PropertyDescriptorMap): any;

Parameters

ParameterDescription
objRequired. The object that will receive the properties.
propsRequired. An object whose keys are property names and whose values are property descriptors.

Return Value

Return ValueDescription
objectThe same obj, after the properties are defined.

JavaScript Examples

Example 1 — Basic Use

Define two properties on an empty object in one call.

JavaScript
var person = {};
Object.defineProperties(person, {
  name: {
    value: "Alex",
    writable: true,
    enumerable: true,
    configurable: true
  },
  age: {
    value: 30,
    writable: false,
    enumerable: true,
    configurable: true
  }
});

console.log(person.name);  // Alex
console.log(person.age);   // 30
Try It Yourself

How It Works

  1. Empty start. person begins with no own properties.
  2. Define both keys. defineProperties adds name and age with the given descriptors.
  3. Read the values. Both properties work like normal data fields when you read them.

Example 2 — Writable Flag

A non-writable property keeps its value when you try to change it (non-strict mode).

JavaScript
var person = {};
Object.defineProperties(person, {
  age: {
    value: 30,
    writable: false,
    enumerable: true,
    configurable: true
  }
});

person.age = 99;
console.log(person.age);  // 30
Try It Yourself

How It Works

  1. Lock the value. writable: false means the stored value should not change.
  2. Assignment ignored. In non-strict mode, person.age = 99 fails quietly.
  3. Value stays. age is still 30.

Example 3 — Enumerable Keys

Only enumerable properties show up in Object.keys().

JavaScript
var person = {};
Object.defineProperties(person, {
  name: {
    value: "Alex",
    writable: true,
    enumerable: true,
    configurable: true
  },
  age: {
    value: 30,
    writable: false,
    enumerable: true,
    configurable: true
  }
});

console.log(Object.keys(person).join(","));  // name,age
Try It Yourself

How It Works

  1. Both enumerable. Each descriptor sets enumerable: true.
  2. Keys lists them. Object.keys returns the enumerable own names.
  3. Hide if needed. Set enumerable: false when a property should stay out of key lists.

Browser & Runtime Support

Object.defineProperties() has been part of JavaScript since ES5 and is Baseline Widely available.

✓ Baseline · ES5

Object.defineProperties()

Supported in all modern browsers and Node.js. Also available in Internet Explorer 9+.

99% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Object.defineProperties Excellent

Bottom line: Safe to use everywhere modern JavaScript runs. Pair it with getOwnPropertyDescriptor to inspect flags.

Frequently Asked Questions

It defines or updates several properties on one object using a map of property descriptors, then returns that object.
defineProperty() sets one property. defineProperties() sets many properties in a single call.
value is the data. writable controls assignment. enumerable controls key listing. configurable controls whether the property can be deleted or redefined.
No. Use normal assignment for everyday fields. Use descriptors when you need flags like non-writable or non-enumerable.
It returns the same object you passed in as the first argument.

Next: defineProperty()

Add or change one property with a descriptor.

defineProperty() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful