You can invoke constructors in JS w/o the parenthesis if no parameters are to be passed, the effect is the same.
new Date()
vs new Date
the same.
However, it makes a difference when you want to call a method on the resulting object:
new Date().getTime()
works but new Date.getTime()
would not because in the latter case the interpreter assumes getTime
is a method of the Date type but that's not true, getTime
is an instance method - only exists in constructed objects. To overcome this you can wrap parenthesis around the constructor call to tell the interpreter that it is an expression:
(new Date).getTime()
This way first the expression is evaluated and getTime
is called on the result which is an instance of Date.