JS new.target vs. instanceof
问题 So I have done some reading on the new.target boolean added in Node 6.x. Here is a simple example of new.target provided on MDN function Foo() { if (!new.target) throw "Foo() must be called with new"; console.log("Foo instantiated with new"); } Foo(); // throws "Foo() must be called with new" new Foo(); // logs "Foo instantiated with new" But this reads a lot like what I am presently using the below code for var Foo = function (options) { if (!(this instanceof Foo)) { return new Foo(options);