In JavaScript, it seems you can do either write:
new Date().getTime();
…or:
(new Date).getTime();
The first one is logical, but the second one seems a little unusual to me… Is there any difference between these two ways of creating a Date object, and what is the purpose of the second?
Thanks,
Steve
It seems that in javascript you can call constructor without parethesis. At least it works with my Firefox. So (new Date) == new Date()
Implying from that both expressions are equivalent. Alternatively you could write
Which is what I usually do.
And I think it’s just matter of personal preference. The new operator takes precedence before the . operator but the visual might suggest the other way round…