I'm running a simple test and i get a strange behaviour, here is the js code:
var handler = function(index,params){
params.id = index;
}
function test(){
var params = {'id':0};
console.log(params);
gradualRepetitionCalls(0,10,params);
}
function gradualRepetitionCalls(index, maxIndex,params)
{
if (index < maxIndex)
{
handler(index,params);
index++;
gradualRepetitionCalls(index,maxIndex,params);
}
}
test();
The strange thing is that the console.log(params) shows that the id is '9' while i would expect it to be '0'. Is console.log() asynchronous?
var a = {'id': 0}; console.log(a); a.id = 1;