I was looking through some code. this code, to be exact (the script is inline with the html. here it is on hastebin).
In the code, I came across the following line:
var now = +new Date();
I am a bit confused by what it does. Here are my thoughts so far:
At first, I thought that maybe it is just a different way of writing a += x
. However, I have disproven that theory based on the fact that now
is initialized in the same line, and you can't do var a += x;
My final theory is that var a = +new B();
is the same thing as var a = new Date.now();
, so something like var time = +new Date();
would be equivalent to var time = new Date.time();
. I came to this conclusion because of the fact that the next line, var render_timestamp = now - (1000.0 / server.update_rate);
subtracts a number from now
, and since new Date()
returns yyyy-mm-tttt:hh:mm.ss
, var now = +new Date();
must somehow return a number, so that the next line is able to do arithmetic on it.
Can anybody explain what this syntax (var a = +new B();
)? Any insights would be much appreciated.