Re:Node.js Best Practices
by LazerBear on Friday September 19, 2014 @08:12PM
(#8343161)
That's a cool trick, though 'instanceof' won't work in this case.
[ Parent
| on HN ]
Yup. The proper way to emulate new is
Foo.call(Object.create(Foo.prototype))Douglas Crockford, is that you? Oh the lengths people will go to avoid using 'new'...
I wonder if any linters out there warn when they see something like:
something = SomeCapitalizedFunction()
Because forgetting to use 'new' is really the only thing I could think of that makes this pattern dangerous.Yes, jslint and jshint both do, by default, iirc. They'll also warn on the opposite (using 'new' with a function that doesn't start with an uppercase letter).