在JavaScript中,for(;;){...}的作用是什么? [英] In JavaScript what does for(;;){...} do?
本文介绍了在JavaScript中,for(;;){...}的作用是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在一些JavaScript代码中看到了这一点,但我不明白它的作用.
I've seen this in some JavaScript code but I don't get what it does.
for(;;){
//other code
}
我习惯于 for(i = 0; i< someLength; i ++){...}
格式,但是我一直想弄清楚(;;)语法适用于?
I'm used to the for(i=0;i<someLength;i++){...}
format but I'm stuck to figure out how or what the "(;;)" syntax is for?
推荐答案
在JavaScript中, for(;;){...}
只会创建一个无限的无限循环,几乎完全一样为:
In JavaScript, for (;;) { ... }
just creates an infinite endless loop, which is almost exactly the same as:
while (true) {
// ...
}
或
do {
// ...
} while (true);
这篇关于在JavaScript中,for(;;){...}的作用是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文