function takesTime(){ for (var i = 0; i
for (var i = 0; i < someVeryLargeNumber; ++i) { setTimeout(function () { //do something synchronous }, 0); }
Also see setZeroTimeout to gain a few milliseconds each loop, although the work people are doing there seems to be browser-based.