JavaScript valueOf()Method
Examples
Returns the primitive numeric value of a Number object:
var num = 15;
var n = num.valueOf();
var n = num.valueOf();
nOutput:
Try it yourself »
Definition and Usage
The valueOf() method can return a number as a string.
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the valueOf() method
Syntax
number.valueOf()
Return Value
| Type | Description |
|---|---|
| Number | The primitive value of a number |
Technical Details
| JavaScript version: | 1.1 |
|---|
Other Extensions
JavaScript Number Object