title: Scoping of params in callbacks with closure
body: <p>I know there have been many questions asked on this topic but I was interested in the difference between two particular scenarios.  Here it is</p>
  
  <p>Scenario 1</p>
  
  <pre><code>   //Global Scope
  var a=1, b =2;
  
  var callBackFn = function(param3,param4){
      alert(a);             //1  --&gt;defined
      alert(b);             //2  --&gt;defined
      alert(param1);        //3  --&gt;? 
      alert(param2);        //4  --&gt;? 
      alert(param3);        //5  --&gt;defined 
      alert(param4);        //6  --&gt;defined
      alert(localVariable); //7  --&gt;?
  }
  
  
  var classObj = {
  
      someMemberFunction: function(param1, param2{
          var localVariable; 
          return $.AsyncCallFn(param1, param2).then(function(){
             callBackFn(3,4);
          });
      }
  
  };
  
  classObj.someMemberFunction(5,6);
  </code></pre>
  
  <p>Scenario 2</p>
  
  <pre><code>    //Global Scope
  var a=1, b =2;
  
  var classObj = {
  
      someMemberFunction: function(param1, param2){
          var localVariable; 
          $.AsyncCallFn(param1, param2).then(function(param3,param4){
              alert(a);             //1  --&gt;?
              alert(b);             //2  --&gt;?
              alert(param1);        //3  --&gt;? 
              alert(param2);        //4  --&gt;? 
              alert(param3);        //5  --&gt;? 
              alert(param4);        //6  --&gt;? 
              alert(localVariable); //7  --&gt;?
          });
      };
  
  }
  
  classObj.someMemberFunction(5,6);
  </code></pre>
  
  <p>What would be the outputs of the alerts #1 through #6
  and more importantly would there be any difference in scenario 1 and scenario 2.</p>
  
  <p>From my understanding in scenario 1 callBackFn will know nothing about param1, param2 and localVariable because it was not created inside someMemberFunction.  But for scenario 2, should someMemberFunction not be aware of param1, param2 and localVariable as well, because it is a closure inside someMemberFunction? </p>
  
  <p>Thanks</p>