close
The Wayback Machine - https://web.archive.org/web/20221013225032/https://www.geeksforgeeks.org/javascript-string-valueof/amp/

JavaScript string.valueOf() Method

Below is the example of the string.valueOf() Method. 
 




<script>
    var a = new String("GeeksforGeeks");
    document.write(a.valueOf());
</script>

GeeksforGeeks

The string.valueOf() is an inbuilt method in JavaScript which is used to return the value of the given string.
Syntax: 
 

string.valueOf()

Parameters: It does not accept any parameter.
Return Values: It returns a string which represent the value of the given string object.
JavaScript code to show the working of string.valueOf() method: 
Program 1: 
 




<script>
    // Taking a string as input and printing it
    // with the help of string.valueOf() function
    var a = new String("GeeksforGeeks");
    document.write(a.valueOf());
</script>

Output: 
 



GeeksforGeeks

Program 2: 
 




<script>
    // Taking a string as input and printing it
    // with the help of string.valueOf() function
    var a = new String("Geeks");
    var b = new String("for");
    var c = new String("Geeks");
    document.write(a.valueOf(),b.valueOf(),c.valueOf());
</script>

Output: 
 

GeeksforGeeks

 

Supported Browser:


Article Tags :