The value of this inside a function depends on how the function is invoked. If we simply invoke a function in non-strict mode, the value of this within the function will point to the global object as follows:
function f1() { return this; } f1() === window; // true
However, if we invoke a function in strict mode, the value of this within the function's body will point to undefined as follows:
console.log(this); // global (window) function f2() { "use strict"; return this; // undefined } console.log(f2()); // undefined console.log(this); // window