Variables in JavaScript are lexically scoped. But, I wonder, is the this keyword, referring to the receiver of a method, an example of dynamic scoping. Or is this unrelated to the lexical/dynamic scoping discussion?
var foo = { x = “how am I scoped?” }
function bar() {
console.log(this.x) // the free variable this is decided by the calling context, like I see dynamic scoping described
}
foo.bar()