I want to use a timer as a fallback in case I end up in an infinite loop. It seems that set interval is the right way to do this. However, it\'s not working for me.
Fro
Browser javascript runs in a single thread. So if you perform something that takes too long - it will freeze browser.
See John Resig article for further details: http://ejohn.org/blog/how-javascript-timers-work/
After you read that article you'll get that your setInterval
callback queued to be run in 1000ms after now but only after the current code is finished. It cannot finish though, because of the infinite loop.