I'm figuring out the lexical environment of the constructor in class.
class Func {
constructor() {}
}
As far as I concerned, new Func() would call the internal method [[Construct]] which refers to Func.prototype.constructor and it points at Func at the end.
The point is, what would be the Outer Lexical Environment Reference of this constructor? and how the Execution Context goes on this?
For example, when you try to make a new Promise, an example starts like this;
const foo = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('good');
}, 5000);
});
new Promise() calls [[Construct]] in Promise, and it goes to Promise.prototype.constructor() which is exactly same as Promise.
At this moment, does the executed constructor behave as it is called from the global scope? It is very vague for me to figure out who's calling who.