How do I detect and stop an infinite loop in user-provided JavaScript?

I am writing an editor in a browser for games. The editor will allow users to write their own JavaScript files, which are then loaded into the same DOM as in the editor. This will allow them to see the game in a canvas next to the code and update it every time they save.

The editor is for people who are not familiar with JavaSript and it can be easy to accidentally end up with an infinite loop. If possible, I want to set up my editor in such a way that if the loop runs too many times or too fast, the loop breaks and a message pops up warning the user that they have an infinite loop.

This would be ideal for people who are new, because if the whole editor just crashed suddenly, they might not understand what their mistake is and think it's a problem with my editor.

How can I implement fail-safe functions in my editor that stop infinite loops automatically?

+3
javascript editor infinite-loop


source to share


No one has answered this question yet

Check out similar questions:

7649
How does JavaScript blocking work?
7494
How can I remove a specific element from an array in JavaScript?
7432
How to check if a string contains a substring in JavaScript?
5722
How can I remove a property from a JavaScript object?
4829
How do I include a JavaScript file in another JavaScript file?
3999
How do I replace all occurrences of a string?
3998
How to validate an email address in JavaScript
3796
How do you get the timestamp in JavaScript?
2893
Looping through an array in JavaScript
2660
Closing JavaScript Inner Loops - A Simple Practical Example



All Articles
Loading...
X
Show
Funny
Dev
Pics