.valueOf() method returns the primitive value of a
String object, similar to the
Note: Objects that are descendants of the
Strings, inherit the
.valueOf() method takes no parameters.
All primitive string values are wrapped in a
String object (
new String(value)). In the following example, this primitive value is returned by the
const name = new String('Bill');console.log(name);console.log(name.valueOf());
This will print the following:
Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.
Front-End EngineerFront-end engineers work closely with designers to make websites beautiful, functional, and fast.
Includes 34 Courses
With Professional Certification