3 ms·
Deferring until next tick is one way to get around call stack problems. If you create a really big series of callbacks which will call other callbacks which ca
by fenwick67 9y ago
Deferring until next tick is one way to get around call stack problems. If you create a really big series of callbacks which will call other callbacks which call other callbacks... you can run out of call stack.
The other issue is let's say you have some code like...
var f = 1
doSomeOperation(function done(){
console.log(f)
})
f = 5
If doSomeOperation calls done() sometimes syncronously and sometimes asynchronously, it will sometimes log 1 and sometimes log 5. If doSomeOperation always works one way it's more consistent. It's not a perf thing it's just consistency.