var obj = {
log: function() {
console.log(this);
var nestedLog = function() {
console.log(this);
}
nestedLog();
}
};
obj.log();
.as-console-wrapper { max-height: 100% !important; top: 0; }
and then i get
{log: ƒ}
Window {postMessage: ƒ, blur: ƒ, focus: ƒ, close: ƒ, parent: Window, …}
Can somebody explain me why this
binding is gone? I didn't execute nestedLog
from global execution context but still i got window
object from this
binding. I can't really understand why it's happening. I know that this
binding depends on execution context and if i do something like this:
var log = obj.log;
log()
it's obvious that i get window
object. But when i execute nestedLog
inside obj.log
function, shouldn't this
binding stay the same? Can somebody explain me how does it work?