constructor property (Definition)

A reference to a constructor function.

Availability:

ECMAScript edition - 2

A constructor property is a function object that creates and initializes new objects. Each constructor has an associated prototype object that provides inheritance and shared properties.

There are constructor properties belonging to the Global object for all the Built-in (Native) object prototypes. These constructors are available as part of the core language from the global object. They are defined in the ECMA standard at editions 2 and 3. The host implementation may add others for you to use:

To create new objects, a new expression is formed with the constructor as its operand. The result is to create a new object by means of the constructor.

For any object the constructor is a property of the prototype. The prototype is a property of the object and the constructor points back at the object. In that sense the prototype and constructor properties each point at the other's parent object.

This needs to hold true for a constructor to be correctly set up:

myObject.prototype.constructor

is the same as:

myObject

They should test true with the === operator since they are supposed to be identical objects.

Warnings:

See also:Construct, Global object, prototype property

Cross-references:

ECMA 262 edition 2 - section - 4.3.4

ECMA 262 edition 2 - section - 15.1.3

ECMA 262 edition 3 - section - 4.3.4