Javascript examples for String:valueOf
The valueOf() method returns the primitive value of a String object.
None
A String, representing the primitive value of a string
The following code shows how to Return the primitive value of a string object:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from ww w .j av a2 s .com var str = "Hello World!"; var res = str.valueOf(); document.getElementById("demo").innerHTML = res; } </script> </body> </html>