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.
As has been already said - the callback to setInterval doesn't run until the infinite loop finishes. To do what you are trying to achieve - without using web workers - you have to check the time from the loop itself: