how do I create an infinite loop in JavaScript [duplicate]

Solution 1:

You can also use a while loop:

while (true) {
    //your code
}

Solution 2:

By omitting all parts of the head, the loop can also become infinite:

for (;;) {}