Baseline Widely available
The valueOf()
method of Symbol
values returns this symbol value.
const symbol1 = Symbol("foo");
console.log(typeof Object(symbol1));
// Expected output: "object"
console.log(typeof Object(symbol1).valueOf());
// Expected output: "symbol"
Syntax Parameters
None.
Return valueThe primitive value of the specified Symbol
object.
The valueOf()
method of Symbol
returns the primitive value of a Symbol object as a Symbol data type.
JavaScript calls the valueOf()
method to convert an object to a primitive value. You rarely need to invoke the valueOf()
method yourself; JavaScript automatically invokes it when encountering an object where a primitive value is expected.
const sym = Symbol("example");
sym === sym.valueOf(); // true
Specifications Browser compatibility See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4