Example
Return the primitive value of a string object:
var str = "Hello World!";
var res = str.valueOf();
The result res of will be:
Hello World!
Try it Yourself »
Definition and Usage
The valueOf() method returns the primitive value of a String object.
Note: This method is usually called automatically by JavaScript behind the scenes, and not explicitly in code.
Browser Support
Method | |||||
---|---|---|---|---|---|
valueOf() | Yes | Yes | Yes | Yes | Yes |
Syntax
string.valueOf()
Parameters
None |
Technical Details
Return Value: | A String, representing the primitive value of a string |
---|---|
JavaScript Version: | 1.1 |
< JavaScript String Reference