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:
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:

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 valueOf
Post your Comment