JavaScript String - valueOf() Method


Advertisements


Description

This method returns the primitive value of a String object.

Syntax

Its syntax is as follows −

string.valueOf( )

Return Value

Returns the primitive value of a String object.

Example

Try the following example.

Live Demo
<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>

Output

Hello world

javascript_strings_object.htm

Advertisements