You are on page 1of 1

JavaScript Object in Depth

You have already learned about JavaScript object in the JavaScript Basics section.
Here, you will learn about object in detail.

As you know, object in JavaScript can be created using object literal, object
constructor or constructor function. Object includes properties. Each property can
either be assigned a literal value or a function.

Consider the following example of objects created using object literal and
constructor function.

Property Descriptor
In JavaScript, each property of an object has property descriptor which describes
the nature of a property. Property descriptor for a particular object's property
can be retrieved using Object.getOwnPropertyDescriptor() method.

The getOwnPropertyDescriptor method returns a property descriptor for a property


that directly defined in the specified object but not inherited from object's
prototytpe.

The following example display property descriptor to the console.

As you can see in the above output, the property descriptor includes the following
4 important attributes.

You might also like