JavaScript valueOf()Method
Example
Return the primitive value of a Date object:
var d=new Date();
var n=d.valueOf();
var n=d.valueOf();
nOutput:
Try it Yourself »
Definition and Usage
The valueOf() method returns the primitive value of a Date object.
Note:The primitive value returns the number of milliseconds since midnight January 1, 1970!
Browser Support
![]()
![]()
![]()
![]()
![]()
valueOf() - All major browsers support the valueOf() method.
Syntax
Date.valueOf()
Return Value
| Type | Description |
|---|---|
| Number | The millisecond representation of date. The return value is equal to the value returned by the Date.getTime method, which is the number of milliseconds since midnight January 1, 1970. /td> |
Technical Details
| JavaScript Version: | 1.1 |
|---|
Other Extensions
JavaScript Date Object