Baseline Widely available
The valueOf()
method of Number
values returns the value of this number.
const numObj = new Number(42);
console.log(typeof numObj);
// Expected output: "object"
const num = numObj.valueOf();
console.log(num);
// Expected output: 42
console.log(typeof num);
// Expected output: "number"
Syntax Parameters
None.
Return valueA number representing the primitive value of the specified Number
object.
This method is usually called internally by JavaScript and not explicitly in web code.
Examples Using valueOfconst numObj = new Number(10);
console.log(typeof numObj); // object
const num = numObj.valueOf();
console.log(num); // 10
console.log(typeof num); // number
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