Javascript Array constructor

The JavaScript Array constructor property returns the constructor function for the array.

The syntax to access the constructor property is:

arr.constructor

Here, arr is an array.


Return value from constructor

  • Returns the constructor function for the array.

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

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


Example : Using constructor property

let array = [1, 2, 3, 4, 5];

let constructor = array.constructor;

console.log(constructor) //  Array() { [native code] }

Output

Array() { [native code] }

Recommended Reading: JavaScript Constructor Function