In the script shown below
$(function(){
var outerValue="OuterValue";
$('#btnScope').click(function(){
alert(outerValue);
});
});
The outer function (ie $()) executes when the page loads. At this time click event will be bound to anonymous function (which alerts). This function uses value of outerValue which might have lost scope after completing the ready($()) function. How this is possible? How could I know the scope of variable?
How the interpreter define its scope?