3 ms·
Here's a counter-argument. var x = new Foo() ...is almost universally recognizable, and leaves little guesswork about the intent and meaning of the code.
by _greim_ 12y ago
Here's a counter-argument.
var x = new Foo()
...is almost universally recognizable, and leaves little guesswork about the intent and meaning of the code. There's a lot more ambiguity encountering this:
var x = foo()
What am I getting back? A primitive value? An instance? A singleton? I have to go peruse the docs. `new` can definitely be abused to do non-intuitive things, but it's still a powerful signal to future readers of the code.
- mattdesl 12y agoName your factory "createFoo", problem solved. :)