javascript - Weird use Date object -


+ + new date 

output

1429943200207

i saw strange statement in our thirdparty plugin. tried break logic can't. returns current time in ms same new date().gettime().

is alternate way return in current time ms?

how works?

when put unary + before value, converted number.

+ new date 

is equivalent to

number(new date) 

and converting date number returns time in milliseconds, they're both equivalent to

(new date).gettime() 

i'm not sure why have 2 +, though. maybe first 1 part of larger expression, like

"the timestamp " + + new date 

then first + concatenation.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -