简体   繁体   English

Google Chrome浏览器中的无限循环

[英]Infinite Loop in Google Chrome

I think the Javascript code below works like this: 我认为以下JavaScript代码的工作方式如下:

i = 0 first time around.
i = 3 second time.
i = 6 third time.
i = 9 end of loop. 

So the loop should run 3 times, but in Google Chrome it becomes an infinite loop. 因此该循环应运行3次,但在Google Chrome浏览器中它将变为无限循环。 Is there something I'm missing? 有什么我想念的吗? (complete beginner) (完整的初学者)

for (var i = 0; i < 9; i + 3) {
    console.log('hey');
}

Another detail: I've been using visual studio code live server. 另一个细节:我一直在使用Visual Studio Code实时服务器。

I've experimented with different variations and get the same problem. 我尝试了不同的变体并遇到了相同的问题。

One variation: 一种变化:

for (var i = 0; i < 10; i + 2) {
    console.log('hey');
}

i + 3 doesn't change i . i + 3不会改变i You probably meant i += 3 . 您可能是说i += 3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM