function test1() {
this.name = 'test1';
var that = this;
function test2() {
this.name = 'test2';
console.log(that.name);
}
test2();
}
test1();
When this executes, I expect the console to log out test1
. Why do I get test2
instead? I expect the that
variable to hold a reference to the test1
function.