Javascript Array constructor

The constructor property returns the constructor function for the array.

Example

let languages = ["JavaScript", "Java", "Python"];

let constructor = languages.constructor;
console.log(constructor)

// Output:
// [Function: Array]

constructor Syntax

The syntax to access the constructor property is:

arr.constructor

Here, arr is an array.


constructor Parameters

The constructor is a property in JavaScript, so it doesn't take any parameters.


constructor Return Value

  • 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) 

Output

[Function: Array]

Also Read:

Did you find this article helpful?

Your builder path starts here. Builders don't just know how to code, they create solutions that matter.

Escape tutorial hell and ship real projects.

Try Programiz PRO
  • Real-World Projects
  • On-Demand Learning
  • AI Mentor
  • Builder Community