In this example you will study how to use the constructor property in JavaScript. The constructor property of JavaScript returns a reference to the array function that creates the object. You can see in the given example, we have create an instance of Array class. Then we have used the array.constructor property which returns the function name.
Here is the code:
| <html> <head> <h2>JavaScript Array constructor Property</h2> <script type="text/javascript"> var array = new Array("Rose", "India", "Technologies"); document.write("<b>The function of this object's instance is: </b>" + array.constructor+"<br>"); </script> <body bgcolor="lightBlue"/> </head> <b>[The array.constructor property returns the function that created the object's instance.]</b> </html> |
Output will be displayed as:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: JavaScript Array Constructor
Post your Comment