JS Built-ins
← Number105 / 105
NumbervalueOfintermediate

valueOf() β€” comparison with primitive

πŸ“– 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() and Comparison

A Number object loosely equals its primitive value because == calls valueOf().

πŸ’‘ Hints (1)
  • β€’ Loose equality (`==`) triggers `valueOf()` on objects; strict equality (`===`) does not.