The Wayback Machine - https://web.archive.org/web/20230512160258/https://www.geeksforgeeks.org/javascript-string-valueof/
Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

JavaScript String valueOf() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The JavaScript String valueOf() Method is an inbuilt method in JavaScript that 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 that represents the value of the given string object.

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

Example 1: 

javascript




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

Output: 

GeeksforGeeks

Example 2: 

javascript




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

Output: 

GeeksforGeeks

Example 2: 

javascript




<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");
    console.log(a.valueOf(),b.valueOf(),c.valueOf());
</script>

Output: 

GeeksforGeeks

We have a complete list of Javascript string methods, to check those please go through this Javascript String Complete reference article.

Supported Browser:

  • Chrome 1 and above
  • Edge 12 and above
  • Firefox 1 and above
  • Internet Explorer 4 and above
  • Opera 3 and above
  • Safari 1 and above

We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript.


My Personal Notes arrow_drop_up
Last Updated : 01 Dec, 2022
Like Article
Save Article
Similar Reads
Related Tutorials