Javascript examples for Number:valueOf
The valueOf() method returns the primitive value of a number.
None
A Number, representing the primitive value of a number
The following code shows how to return the primitive value of a number:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {// w w w. ja va 2s. co m var num = 15; var n = num.valueOf() document.getElementById("demo").innerHTML = n; } </script> </body> </html>