en.javascript.info/1-js/04-object-basics/06-constructor-new/1-two-functions-one-object/solution.md
2018-09-28 14:17:35 +03:00

309 B

Yes, it's possible.

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

So they 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