new MyClass(); vs new MyClass;
Posted
by Bytecode Ninja
on Stack Overflow
See other posts from Stack Overflow
or by Bytecode Ninja
Published on 2010-06-14T04:22:41Z
Indexed on
2010/06/14
4:32 UTC
Read the original article
Hit count: 177
JavaScript
In some JavaScript code snippets (e.g. http://mckoss.com/jscript/object.htm) I have seen objects being created in this way:
var obj = new Foo;
However, at least at MDC, it seems that the parentheses are not optional when creating an object:
var obj = new Foo();
Is the former way of creating objects valid and defined in the ECMA standard? Are there any differences between the former way of creating objects and the later? Is one preferred over the other?
Thanks in advance.
© Stack Overflow or respective owner