Easy Tutorial
❮ Prop Date Disabled Jsref Tolocalelowercase ❯

JavaScript constructor Property

JavaScript Array Object

Example

Return the function that created the prototype of the fruits array object:

fruits.constructor;

Result output:

function Array() { [native code] }

Definition and Usage

In JavaScript, the constructor property returns the constructor function for an object.

The return value is a reference to the function, not the name of the function:

JavaScript array constructor property returns function Array() { [native code] }

JavaScript number constructor property returns function Number() { [native code] }

JavaScript string constructor property returns function String() { [native code] }

If a variable is an array, you can use the constructor property to determine this.


Browser Support

Property
constructor Yes Yes Yes Yes Yes

The constructor property is supported by all major browsers.


Syntax

Technical Details

Return Value: A function object. This function is the one that originally created the array object.
JavaScript Version: 1.1
--- ---
❮ Prop Date Disabled Jsref Tolocalelowercase ❯