Home >>JavaScript Array Reference >JavaScript Array valueOf() Method
JavaScript valueOf() method is used to return the given input array. It does not change the original given array. It does not contain any parameter value.
Syntax:array.valueOf()
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
valueOf() | Yes | Yes | Yes | Yes | Yes |
<html> <body> <p>Click the button to see the Output.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { var x = ["A", "B", "C", "D", "E", "F"]; document.getElementById("demo").innerHTML = x.valueOf(); } </script> </body> </html>
Click the button to see the Output.
<html> <body> <p>Click the button to see the Output.</p> <button onclick="myFunction1()">Try it</button> <p id="demo1"></p> <script> function myFunction1() { var x = [1, 2, 3, 4, 5, 6, 7, 8, 9]; document.getElementById("demo1").innerHTML = x.valueOf(); } </script> </body> </html>
Click the button to see the Output.