title: Arguments to JavaScript Anonymous Function
body: <pre><code>for (var i = 0; i &lt; somearray.length; i++)
  {
      myclass.foo({'arg1':somearray[i][0]}, function()
      {
          console.log(somearray[i][0]);
      });
  }
  </code></pre>
  
  <p>How do I pass somearray or one of its indexes into the anonymous function ?
  somearray is already in the global scope, but I still get <strong>somearray[i] is undefined</strong></p>