In JavaScript what does for(;;){…} do?

前端 未结 5 1011
感动是毒
感动是毒 2021-01-26 08:40

I\'ve seen this in some JavaScript code but I don\'t get what it does.

for(;;){

  //other code

}

I\'m used to the for(i=0;i

5条回答
  •  时光取名叫无心
    2021-01-26 09:33

    In JavaScript, for (;;) { ... } just creates an infinite endless loop, which is almost exactly the same as:

    while (true) {
        // ...
    }
    

    or

    do {
        // ...
    } while (true);
    

提交回复
热议问题