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

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -