JavaScript Object.getOwnPropertyDescriptors() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Object

Definition

Object.getOwnPropertyDescriptors(obj) returns a plain object whose keys are the own property names and symbols of obj. Each value is a full property descriptor: value, writable, enumerable, configurable (or get/set for accessors).

Inherited properties are ignored. Use this when you need to copy or inspect flags — not just values — for example before Object.defineProperties() or Object.create().

Syntax

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

JavaScript
Object.getOwnPropertyDescriptors(obj)
CallWhat it does
Object.getOwnPropertyDescriptors(obj)Returns an object of every own property descriptor on obj.

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

Library declarations
JavaScript
Object.getOwnPropertyDescriptors(obj)
JavaScript
getOwnPropertyDescriptors(o: any): { [p: string]: PropertyDescriptor };

Parameters

ParameterDescription
objRequired. The object whose own property descriptors you want. Primitives are boxed first.

Return Value

Return ValueDescription
objectA new object mapping each own key (string or symbol) to its property descriptor.

JavaScript Examples

Example 1 — Basic Use

Read descriptors for a small object and print a few flags.

JavaScript
var user = {
  name: "Ada",
  age: 36
};

var all = Object.getOwnPropertyDescriptors(user);
console.log(all.name.value);
console.log(all.name.writable);
console.log(all.age.enumerable);
Try It Yourself

How It Works

  1. Build an object Normal object literals create data properties that are writable, enumerable, and configurable.
  2. Read all descriptors Object.getOwnPropertyDescriptors(user) returns one descriptor object per own key.
  3. Inspect flags Each descriptor has value plus writable, enumerable, and configurable.

Example 2 — Hidden Properties

Descriptors include non-enumerable own properties that Object.keys() skips.

JavaScript
var box = {};
Object.defineProperty(box, "secret", {
  value: 42,
  enumerable: false,
  writable: true,
  configurable: true
});

console.log(Object.keys(box));
var desc = Object.getOwnPropertyDescriptors(box).secret;
console.log(desc.value);
console.log(desc.enumerable);
Try It Yourself

How It Works

  1. Hide a property enumerable: false keeps secret out of Object.keys() and for...in.
  2. Still an own property getOwnPropertyDescriptors still returns it because the property belongs to box.
  3. Read the flags The descriptor shows the value 42 and that enumerable is false.

Example 3 — Copy With Flags

Clone an object while keeping non-enumerable properties by copying descriptors.

JavaScript
var source = {};
Object.defineProperty(source, "id", {
  value: 7,
  enumerable: false,
  writable: false,
  configurable: true
});
source.label = "item";

var copy = Object.create(
  Object.getPrototypeOf(source),
  Object.getOwnPropertyDescriptors(source)
);

console.log(copy.label);
console.log(Object.getOwnPropertyDescriptor(copy, "id").value);
console.log(Object.keys(copy));
Try It Yourself

How It Works

  1. Mix visible and hidden label is a normal enumerable property; id is non-enumerable.
  2. Copy descriptors Object.create(proto, descriptors) rebuilds the object with the same flags.
  3. Flags survive id is still there and still hidden from Object.keys().

Browser & Runtime Support

Object.getOwnPropertyDescriptors() arrived in ES2017. It is Baseline and available in modern browsers and Node.js.

✓ Baseline · ES2017

Object.getOwnPropertyDescriptors()

Supported in Chrome 54+, Firefox 50+, Safari 10+, Edge 15+, and Node.js 7+.

97% 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.getOwnPropertyDescriptors Excellent

Bottom line: Safe for modern apps. For older engines, copy one property at a time with Object.getOwnPropertyDescriptor().

Frequently Asked Questions

It returns an object that maps every own property name and symbol to its full property descriptor (value/flags or get/set).
No. Only own properties on the object itself are included. Prototype properties are skipped.
getOwnPropertyDescriptor reads one key. getOwnPropertyDescriptors returns descriptors for all own keys at once.
Yes. Symbol own properties appear as keys on the returned object, just like string keys.
Object.assign copies only enumerable string keys and loses writable/enumerable/configurable flags. Descriptors keep the full definition.

Next: getOwnPropertyNames()

List every own string property name, even hidden ones.

getOwnPropertyNames() 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