ValueOf-1

 

JavaScript valueOf function will return the primitive value of a string. See the code snippet:


 
 
 
<!DOCTYPE html> <html> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <button onclick="convertToPrimitiveValue()">Display the value</button> <p id="sample"></p> <script> function convertToPrimitiveValue() { var str = "I love learnKode"; var result = str.valueOf(); document.getElementById("sample").innerHTML = result; } </script> </body> </html>
Output