Is Using Settimeout(fn, 0) To Defer Code Execution Until After The Current Call Stack Reliable?
I've got a function that is called an unknown number of times. I need to know how many times the function was run so I'm doing: (function () { var i = 0, increment
Solution 1:
setTimeout()
places a function on the queue, which is executed when all the other functions have been run.
If you call setTimeout()
a few times before calling increment()
, you will probably notice the i
variable reaching a value greater than 1.
Post a Comment for "Is Using Settimeout(fn, 0) To Defer Code Execution Until After The Current Call Stack Reliable?"