I'm still wrapping my head around "this". Here I use "this" inside of a function sayFoo
.
I'm surprised that "this" is the window, when I log it from inside sayFoo().
What am I not understanding here about context?
myCoolThing = {
foo: "1",
doSomething: function() {
sayFoo();
function sayFoo() {
console.log(this.foo);
}
}
}
myCoolThing.doSomething(); // Errors with "foo" undefined