I have the following code:
function method(array, index, vr){
for (var i = index; i< array.length; i++ ){
if(condition){
lib.run({
}).then(function(r){
//doSomething
});
}
}
}
run() - is just library method which retu promise. I need to use array and vr variables inside then() but it seems like they out of scope there. Now I do the following to get access for them:
if(condition){
var a = array;
var v = vr;
lib.run({
}).then(function(r){
//doSomething
console.log(v);
});
}
but it looks awfull.
So, What is the correct way to get such variables in then()?
