how do I create an infinite loop in JavaScript

Elise Chant picture Elise Chant · Jul 27, 2014 · Viewed 103.9k times · Source

I want to create an infinite loop in JavaScript.

What are some ways to achieve this:

eg

for (var i=0; i<Infinity; i++) {}

Answer

Pran picture Pran · Jul 27, 2014

You can also use a while loop:

while (true) {
    //your code
}