I'm calling an async function that needs a callback function as parameters.
Here is the javascript code:
for(i in array)
{
var item = array[i];
functionToCall(item[i][1], 50, function(a, b)
{
alert(a + b);
});
}
I cannot edit functionToCall function. What I want to do is using the "item" variable in the callback function like this.
for(i in array)
{
var item = array[i];
functionToCall(item[i][1], 50, function(a, b, c)
{
alert(a + b + c);
}, item);
}
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.
So how can I do that?