Arguments to JavaScript Anonymous Function

Posted by Phonethics on Stack Overflow See other posts from Stack Overflow or by Phonethics
Published on 2010-06-11T15:02:56Z Indexed on 2010/06/11 15:12 UTC
Read the original article Hit count: 159

for (var i = 0; i < somearray.length; i++)
{
    myclass.foo({'arg1':somearray[i][0]}, function()
    {
        console.log(somearray[i][0]);
    });
}

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 somearray[i] is undefined

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about anonymous-function