This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.



Gets the own property descriptor of the specified object. An own property descriptor is one that is defined directly on the object and is not inherited from the object’s prototype.


Object.getOwnPropertyDescriptor( object , propertyname )
Required. The object that contains the property.
Required. The name of the property.

Return Value

The descriptor of the property.


The following example gets a data property descriptor and uses it to make the property read-only.

// Create a user-defined object.
var obj = {};

// Add a data property.
obj.newDataProperty = "abc";

// Get the property descriptor.
var descriptor = Object.getOwnPropertyDescriptor(obj, "newDataProperty");

// Change a property attribute.
descriptor.writable = false;
Object.defineProperty(obj, "newDataProperty", descriptor);

To list the property attributes, you can add the following code to this example.

// Get the descriptor from the object.
var desc2 = Object.getOwnPropertyDescriptor(obj, "newDataProperty");

// List the descriptor attributes.
for (var prop in desc2) {
    document.write(prop + ': ' + desc2[prop]);
    document.write("<br />");

// Output:
// value: abc
// writable: false
// enumerable: true
// configurable: true


You can use the Object.getOwnPropertyDescriptor function to obtain a descriptor object that describes attributes of the property.

The Object.defineProperty Function is used to add or modify properties.

See also

Other articles


  • Microsoft Developer Network: Article