Home »
JavaScript
Array constructor property with example in JavaScript
JavaScript array constructor property: Here, we are going to learn about the constructor property of array in JavaScript.
Submitted by IncludeHelp, on February 27, 2019
JavaScript constructor property
constructor property is used to get details of the array's constructor function, it returns the reference to the function.
Syntax
array_name.constructor;
Sample Input/Output
Input:
var arr1 = [10, 20, 30, 40, 50];
Function call:
arr1.constructor;
Output:
function Array() { [native code] }
JavaScript Code to get the constructor details
<html>
<head>
<title>JavaScipt Example</title>
</head>
<body>
<script>
var arr1 = [10, 20, 30, 40, 50];
var arr2 = ["Amit", "Ankur", "Akash"];
var arr3 = [];
document.write("Constructor of arr1: " + arr1.constructor + "<br>");
document.write("Constructor of arr2: " + arr2.constructor + "<br>");
document.write("Constructor of arr3: " + arr3.constructor + "<br>");
</script>
</body>
</html>
Output
Constructor of arr1: function Array() { [native code] }
Constructor of arr2: function Array() { [native code] }
Constructor of arr3: function Array() { [native code] }
JavaScript Array Object Methods »