coffeescript - Why setInterval (->...) ,0 won't run as I expected? -
from coffeescript accelerated javascript development, chapter 6.6, question:
count = 10 h = setinterval (-> count--),100 (->) until count 0 clearinterval h console.log 'suprise!'
count won't 0,i try change 100 0,result same. stack setinterval in? when callback function (-> count--) run?
javascript strictly single-threaded.
asynchronous callbacks run after code finishes running.
your infinite loop never finishes running, setinterval
callback never runs.
Comments
Post a Comment