How to use Array Constructor in JavaScript

In this article I have described about Array Constructor property used in JavaScript.
  • 1977

JavaScript Array Constructor Property

  • As mentioned earlier that for storing multiple values in a single variable we use array object .
  • The array object has a property is known as Constructor Property.
  • With the help of Constructor Property we can create array object's prototype.

Browser support

Following are the main browsers which support the Constructor Property of array object

  • Internet Explorer.
  • Firefox.
  • Opera.
  • Google Chrome.
  • Safari.

Syntax

The Constructor Property of array object has following syntax

Array.constructor

Lets take an example

<!DOCTYPE html>

<html>

<body style = "backgroundcolor:red">

<p id="menu">Create an array and display the constructor</p>

<button onclick="myFunction()">Click</button>

<script type="text/javascript">

    function myFunction() {

        var name = ["Ram", "Shyam", "Rohan", "praveen"];

        var x = document.getElementById("menu");

        x.innerHTML = Array.constructor;

    }

</script>

</body>

</html>

OUTPUT

ARRP1.jpg

When we click on button

ARRP2.jpg

Further Readings

You may also want to read these related articles :here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.