en.javascript.info/1-js/04-object-basics/06-constructor-new/1-two-functions-one-object/solution.md
Ilya Kantor 20784e7f26 up
2017-02-19 01:41:36 +03:00

309 B

Yes, it's possible.

If a function returns an object then new returns it instead of this.

So thay can, for instance, return the same externally defined object obj:

let obj = {};

function A() { return obj; }
function B() { return obj; }

alert( new A() == new B() ); // true