I am new to js and felt that I understood the concept of this until I came across.
function TopLevelFn(){
var obj = {
empId : 232
};
console.log('TopLevelFn() empId :' + obj.empId);
innerFn();
function innerFn(){
//why this points to window object...
console.log('innerFn() empId :' + this.obj.empId);
}
}
var register = new TopLevelFn();
If I understood it clearly the innerFn() is called from TopLevelFn() so the invoking obj and this should be ref to TopLevelFn()?