A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.cdn.mozilla.net/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf below:

Symbol.prototype.valueOf() - JavaScript | MDN

Symbol.prototype.valueOf()

Baseline Widely available

The valueOf() method of Symbol values returns this symbol value.

Try it
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 value

The primitive value of the specified Symbol object.

Description

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.

Examples Using valueOf()
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