Share on Google+Share on Google+

JavaScript array valueOf

Advertisement
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.

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

Advertisements

Advertisement

Posted on: November 10, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Comments:0