title: Javascript - add more parameters to a callback function
body: <p>I'm calling an async function that needs a callback function as parameters.</p>
  
  <p>Here is the javascript code:</p>
  
  <pre><code>for(i in array) 
  {
      var item = array[i];
      functionToCall(item[i][1], 50, function(a, b)
      {
          alert(a + b);
      });
  }
  </code></pre>
  
  <p>I cannot edit functionToCall function. What I want to do is using the "item" variable in the callback function like this.</p>
  
  <pre><code>for(i in array) 
  {
      var item = array[i];
      functionToCall(item[i][1], 50, function(a, b, c)
      {
          alert(a + b + c);
      }, item);
  }
  </code></pre>
  
  <p>But this code doesn't work properly. I cannot just use "item" inside the function because it is always using the last item in array. </p>
  
  <p>So how can I do that?</p>