X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

JavaScript Array constructor Property

JavaScript Array Reference JavaScript Array Reference

Example

The constructor property returns an array's constructor function:

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.constructor;

The constructor property returns:

function Array() { [native code] }

Try it yourself »


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:

For JavaScript arrays the constructor property returns function Array() { [native code] }

For JavaScript numbers the constructor property returns function Number() { [native code] }

For JavaScript strings the constructor property returns function String() { [native code] }

Note You can use the constructor property to define if a variable is an array.


Browser Support

Property
constructor Yes Yes Yes Yes Yes


Syntax

array.constructor

Technical Details

Return Value: function Array() { [native code] }
JavaScript Version: 1.1


JavaScript Array Reference JavaScript Array Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook