I came across this piece of code var timeStamp = 1 * new Date(); and to my surprise it returned value in milliseconds since 1970/01/01. This is equivalent to us
Numeric conversion
It is because of numeric conversion in javascript which is almost same like toString but internally it is called much more often.
Numeric conversion is performed in two main cases:
The explicit conversion can also be done with Number(obj).
The algorithm of numeric conversion:
If valueOf method exists and returns a primitive, then return it.
Otherwise, if toString method exists and returns a primitive, then return it.
Otherwise, throw an exception.
Among built-in objects, Date supports both numeric and string conversion:
alert( new Date() ) // The date in human-readable form
alert( 1*new Date() ) // Microseconds from 1 Jan 1970
Further reading