The valueOf()
method returns the primitive value of a String object.
str.valueOf()
The valueOf()
method of String returns the primitive value of a String object as a string data type. This value is equivalent to str.toString().
This method is usually called internally by JavaScript and not explicitly in code.
valueOf()
var x = new String('Hello world'); console.log(x.valueOf()); // Displays 'Hello world'
Created by Mozilla Contributors, license: CC-BY-SA 2.5