var currentScope = 0;
(function(){
var currentScope = 1, one= 'scope1';
alert(currentScope);
(function(){
var currentScope = 2, two= 'scope2';
alert(currentScope);
alert(one + two);
})();
})();
Now when i execute this code in jsbin, i get the alert as 1 then 2
and then scope 1 and scope 2
. But i came to know that in ExecutionContext
, it will actually call the inner function first which will look for the outer variable
then so on.
- Can anyone tell me how the
ExecutionContext Object
would look like in my function environment. - Correct me if i am wrong, in the browser it would first display the currentScope 1 first, then the CurrentScope 2. But actually behind the scenes in interpreter, it happens vice-versa.