Normally, we can do loops for both arrays and objects to iterate over the properties/values. But loops are blocking. However, timeouts can be used to simulate an async loop. i managed to do it for an array.
//do stuff
(function asyncLoop(i){
//do stuff in the current iteration
if(++i < array.length){
setTimeout(function(){asyncLoop(i);}, 1);
} else {
callback();
}
}(0));
//do stuff immediately after, while looping
but this model only works while looping in an array, where there is a limiter - the i that gets passed around. is there a way to do this over an object? let's just say that the object has 50k keys to iterate through, making it unreasonably long.
i already know of this setImmediate (afaik, only newer IE) and WebWorkers(not yet in IE), but i just want to know if it's possible to just use the same strategy on an object.