JS Built-ins
← Number101 / 105
NumbervalueOfintermediate

valueOf() β€” new Number(42).valueOf() === 42

πŸ“– Usage Example
// Retrieve the primitive numeric value
const n = new Number(42)
n.valueOf()          // β†’ 42
typeof n.valueOf()   // β†’ 'number'

Use valueOf() on a Number object to extract the underlying primitive number value, which JavaScript also calls automatically in numeric expressions.

Number.prototype.valueOf()

numObj.valueOf() returns the primitive numeric value wrapped by a Number object.

new Number(42).valueOf()  // β†’ 42
πŸ’‘ Hints (1)
  • β€’ `valueOf()` unwraps the `Number` object to get the primitive value.