When you invoke a top-level function in Javascript, the this keyword inside the function refers to the default object (window if in a browser). My understanding is that
In JavaScript, when a function is invoked without an explicit context, the context is the global object. In the case of web browsers, the global object is window
.
Additionally, JavaScript has functional scope, so any variables or functions within a function are not accessible in a scope outside of that function. This is why you can't access window.innerFunc
.