String valueOf() function in Javascript
A valueOf() function used to converts string object to primitive value of string. It does not change the original string of string object. This function is the default function for JavaScript strings object which is used internally by JavaScript.
Syntax
 1 <string_object>.valueOf()
string_object : A string object which value needs to be extracted
return : It returns string value from string object
valueOf() function
 1 // string object
 2 let str = "Hello world !";
 3 str.valueOf();
 4 
 5 // string object with new keyword
 6 let str = new String("Hello world");
 7 str.valueOf();
In the above example, we have define string literal and retrieving value of string using valueOf() function. In the second example, we have define string object using new keyword and retrieving value of string object using valueOf() function.
Privacy Policy
Terms of Service
Disclaimer
Contact us
About us