JavaScript constructor Property: Array Object


The constructor property of the array object specifies the function that creates an object's prototype.


Implemented in JavaScript 1.1



Object: The name of the object (Required).


In the following web document, the constructor property returns the reference to the function that creates the object.


<!DOCTYPE html>
<meta charset="utf-8" />
<title>JavaScript Array constructor Property</title>
<meta name="description" content="This document contains an example of JavaScript Array constructor Property" />
<style type="text/css">
h1{color: red;}
<h1>JavaScript Array constructor Property</h1>
<script src="array-constructor-example1.js"></script>

JS Code

var myarray = new Array("Orange", "Apple", "Banana", "Cherry", "Mango");
var newParagraph = document.createElement("p"); //creates a new paragraph element
var newText = document.createTextNode("The object is constructed from : "+myarray.constructor); //creates text along with ouput to be displayed 
newParagraph.appendChild(newText); //created text is appended to the paragraph element created
document.body.appendChild(newParagraph); // created paragraph and text along with output is appended to the document body

View the example in the browser

Practice the example above online

JavaScript Array constructor Property

See also :

JavaScript Core objects, methods, properties.

Previous: Javascript Array Objects - Properties and Methods
Next: JavaScript index Property: Array Object

Test your Programming skills with w3resource's quiz.

Follow us on Facebook and Twitter for latest update.