This method returns the primitive value of a String object.
Its syntax is as follows −
string.valueOf( )
Returns the primitive value of a String object.
Try the following example.
<html> <head> <title>JavaScript String valueOf() Method</title> </head> <body> <script type="text/javascript"> var str = new String("Hello world"); document.write(str.valueOf( )); </script> </body> </html>
Hello world