JavaScript String valueOf() Method
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
let a = new String( "GeeksforGeeks" ); console.log(a.valueOf()); |
Output:
GeeksforGeeks
Example 2:
javascript
// Taking a string as input and printing it // with the help of string.valueOf() method let a = new String( "GeeksforGeeks" ); console.log(a.valueOf()); |
Output:
GeeksforGeeks
Example 3:
javascript
// Taking a string as input and printing it // with the help of string.valueOf() method let a = new String( "Geeks" ); let b = new String( "for" ); let c = new String( "Geeks" ); console.log(a.valueOf(), b.valueOf(), c.valueOf()); |
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
Please Login to comment...