JavaScript constructorProperty
Example
Returns the function that created the fruits array object's prototype:
fruits.constructor;
Result output:
function Array() { [native code] }
Try it Yourself »
Definition and Usage
In JavaScript, the constructor property returns the object's constructor function.
The return value is a reference to the function, not the function name:
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 define it.
Browser Support
| Property | |||||
|---|---|---|---|---|---|
| constructor | Yes | Yes | Yes | Yes | Yes |
All major browsers support the constructor property.
Syntax
array.constructor
Technical Details
| Return value: | A function object. This function is the original creator of the array object. |
|---|---|
| JavaScript Version: | 1.1 |
JavaScript Array Object Other Extensions