[an error occurred while processing this directive]

JavaScript array valueOf

                         

JavaScript array class have valueOf() method which returns the primitive value of the calling array object. This valueOf() method is called automatically by the JavaScript. Syntax for the valueOf() method is given as below:

ArrayObject.valueOf()

In this example we have simply created an array of five elements in our JavaScript and we will be printing this array.

Here is the example code for the HTML file as given below:

 

 

 

<html>
<head>
<title>
JavaScript array valueOf() method example
</title>
<script type="text/javascript">
var arr = new Array(5);
arr[0]="Rose";
arr[1]="India";
arr[2]="Technologies";
arr[3]="Pvt";
arr[4]="Ltd";
document.write("<b>Array is </b>=>"+arr.valueOf()+"<br>");
</script>
</head>
<body bgcolor="#ddcdff">
<h2>
Implementation of valueOf() method on array object 
</h2>
</body>
</html>

Output of the example:

Download Sample Source Code

                         

[an error occurred while processing this directive]