The JavaScript Array constructor property is used to return the constructor function for an array object. It only returns the reference of the function and does not return the name of the function. In JavaScript arrays, it returns the function Array(){ [native code] }.
Syntax:
array.constructor
Return value:
It returns the function reference i.e. function Array() { [native code] }.
Below is an example of the Array constructor property.
Example 1: In this example, the program returns the reference of the function (i.e. function Array() { [native code] } ).
Javascript
function myGeeks() {
let name = [ "sahil" , "Manas" ,
"Sagar" , "Harshit" ];
console.log(name.constructor);
}
myGeeks();
|
Example 2: In this example, the program returns the reference of the function (i.e. function Array() { [native code] } ).
Javascript
let arr = new Array( "Geeks" , "for" , "Geeks" );
console.log( "arr.constructor:" + arr.constructor);
|
Output
arr.constructor:function Array() { [native code] }
Example 3: In this example, the program returns the reference of the function (i.e. function Array() { [native code] } ).
Javascript
let arr = new Array(5, 10, 15);
console.log( "arr.constructor:" + arr.constructor);
|
Output
arr.constructor:function Array() { [native code] }
We have a complete list of Javascript Array methods, to check those please go through this Javascript Array Complete reference article.
Supported Browsers: The browsers supported by JavaScript Array constructor Property are listed below:
- Google Chrome
- Edge
- Firefox
- Opera
- Safari
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
17 Jul, 2023
Like Article
Save Article