The object type is a complex but very important data type. Objects may be any specific or non-specific group of data and functionality.

They are the core of JavaScript as almost everything within is considered to be and object.

Developers may create their own objects by creating instances of the object type and adding properties and methods to it.

Objects are created with the operator new followed by the name of the object type to create.

Following example shows a new object creation:

var o = new Object();

All of the basic properties and methods of the Object type are present on all other more specific and further derived objects; thus each object instance contains following properties and methods:

constructor

The function that was used to create the object (in previous example the constructor is the Object() function itself).

hasOwnProperty(propertyName)

Indicates if the given property exists on the object instance (not on the prototype). The property name is given as a string.

isPrototypeOf(object)

Determines if the object is a prototype of another object.

propertyIsEnuIerable(propertyName)

Indicates if the given property can be enumerated using for-in statement. The property name is given as a string.

toLocaleString()

Returns a string representation of the object that is appropriate for the local (charset) execution.

toString()

Returns a string representation of the object;

valueOf()

Returns a string, number, or Boolean equivalent of the object. It may return the same value as toString().

To learn more about objects and prototypes please visit the following chapters.

 

›› go to examples ››