See https://developer.mozilla.org/en-US/docs/JavaScript/Referenc...
> In the global context (outside of any function), this refers to the global object, whether in strict mode or not.
var o = { a:13, add:function(b){ return this.a + b; } };
o.add(42); // => `55`
var add = o.add;
add(42); // => `NaN`, because `this.a` is (presumably) `undefined`
var a = 3;
add(42); // => `45`, because `this.a` is resolved to `window.a`, as `window` is the global variable used as the method context when we call an unbound function (which is stupid (`null` would have been a way better choice, Brandon)).
This is the sort of thing you learn and just get over to reach the level of javascript mastery. Yeah, some things are silly. But you know what? You only get to write one language to access the dynamic web.// => `45`, because `this.a` is resolved to `window.a`, as `window` is the global variable used as the method context when we call an unbound function (which is stupid (`null` would have been a way better choice, Brandon)).
function(){ var fn2=function(){} if (fn2()){ alert("nobody ever calls me"); } else{ alert("stop calling me!"); } } (no return value is a falsy value)
var data={a:"cow"}; function update(obj){ obj.a="fish"; } update(data); alert(data.a); //"fish"
vs.
var data="cow"; function update(str){ str="fish"; } update(data); alert(data); //"cow"
keep up the great work!