Possible Duplicate:
new MyObject(); vs new MyObject;
What is the difference between new Object and new Object() in JavaScript
What is the difference between,
new ClassName;
and
new ClassName();
?
Do they have the same result?
Possible Duplicate:
new MyObject(); vs new MyObject;
What is the difference between new Object and new Object() in JavaScript
What is the difference between,
new ClassName;
and
new ClassName();
?
Do they have the same result?
There is no difference. Use the latter if you want to pass arguments.
The parentheses are also required in chaining:
new ClassName().method();
Creates new ClassName
object and calls method
on it.
new ClassName.method();
Tries to construct ClassName.method
object