If you have the following code:
var global = this; function A () { function B () { return this; } return B(); } var C = new A(); C === gl
The value of this is determined upon every function call. Because B is called without any context, the value of this is the global object.
this
B
It's possible to preserve this in an outer context by simply copying it:
function A() { var x = this; function B() { return x; } return B(); }