JavaScript String valueOf()
Example
Get the value of a text:
let result = text.valueOf();
The same as:
let result = text;
More examples below.
Description
The valueOf() method returns the primitive value of a string.
The valueOf() method does not change the original string.
The valueOf() method can be used to convert a string object into a string.
See Also:
Note
The valueOf() method is the default method for JavaScript strings.
It is used internally by JavaScript.
Normally, you will not use it in your code.
Syntax
Parameters
Return Value
More Examples
Get the value of a String object:
let result = text.valueOf();
Browser Support
valueOf() is an ECMAScript1 (JavaScript 1997) feature.
It is supported in all browsers:
| Chrome | Edge | Firefox | Safari | Opera |