JavaScript Object.getOwnPropertyDescriptor() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Object

Definition

Object.getOwnPropertyDescriptor(obj, prop) returns the descriptor for one own property: usually value, writable, enumerable, and configurable.

If the property does not exist on the object itself, the result is undefined. Inherited properties are not returned.

Syntax

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

JavaScript
Object.getOwnPropertyDescriptor(obj, prop)
CallWhat it does
Object.getOwnPropertyDescriptor(obj, prop)Returns the descriptor for an own property, or undefined if missing.

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

Library declarations
JavaScript
Object.getOwnPropertyDescriptor(obj, prop)
JavaScript
getOwnPropertyDescriptor(o: any, p: PropertyKey): PropertyDescriptor | undefined;

Parameters

ParameterDescription
objRequired. The object to inspect.
propRequired. The property name (string or Symbol) to look up.

Return Value

Return ValueDescription
object | undefinedA property descriptor object, or undefined when the own property does not exist.

JavaScript Examples

Example 1 — Basic Use

Inspect the descriptor of a normal assigned property.

JavaScript
var car = { brand: "Tata" };
var d = Object.getOwnPropertyDescriptor(car, "brand");

console.log(d.value);        // Tata
console.log(d.writable);     // true
console.log(d.enumerable);   // true
console.log(d.configurable); // true
Try It Yourself

How It Works

  1. Normal assignment. Properties created with = are writable, enumerable, and configurable.
  2. Read the descriptor. getOwnPropertyDescriptor returns those flags plus the value.
  3. All true here. You can change, list, and redefine brand freely.

Example 2 — Locked Property

See how defineProperty flags show up in the descriptor.

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

var d = Object.getOwnPropertyDescriptor(locked, "id");
console.log(d.value + "," + d.writable + "," + d.configurable);
// 7,false,false
Try It Yourself

How It Works

  1. Define with flags. id is created as non-writable and non-configurable.
  2. Inspect it. The descriptor reports value, writable, and configurable.
  3. Flags match. You see 7,false,false, matching the definition.

Example 3 — Missing Property

A property that is not own returns undefined.

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

console.log(Object.getOwnPropertyDescriptor(locked, "missing"));  // undefined
Try It Yourself

How It Works

  1. Ask for a missing key. "missing" was never defined on locked.
  2. Result is undefined. No own property means no descriptor object.
  3. Useful check. Compare the result with undefined before reading .value.

Browser & Runtime Support

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

✓ Baseline · ES5

Object.getOwnPropertyDescriptor()

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.getOwnPropertyDescriptor Excellent

Bottom line: Use it to debug property flags or to copy descriptors when cloning objects carefully.

Frequently Asked Questions

It returns the descriptor for one own property, including value and flags like writable, enumerable, and configurable. If the property is missing, it returns undefined.
No. Only own properties are returned. Inherited keys give undefined even if you can read them through the prototype.
Properties created with obj.key = value are usually writable: true, enumerable: true, and configurable: true.
getOwnPropertyDescriptor reads one property. getOwnPropertyDescriptors returns descriptors for all own properties at once.
When the object has no own property with that name, including when the name exists only on the prototype.

Next: getOwnPropertyDescriptors()

Read every own property descriptor from an object at once.

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