JS Built-ins
← Number103 / 105
NumbervalueOfbeginner

valueOf() β€” primitive number.valueOf() === itself

πŸ“– 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.

valueOf() on a Primitive

Calling valueOf() on a primitive number returns the number itself (autoboxing handles the call).

πŸ’‘ Hints (1)
  • β€’ Autoboxing converts a primitive number to a `Number` object temporarily to call the method.