gpt4 book ai didi

javascript - 空 for 循环 - for(;;)

转载 作者:可可西里 更新时间:2023-11-01 02:30:37 24 4
gpt4 key购买 nike

我正在探索 Google Closure Compiler ,我注意到的一件事是它将 while(true) 转换为 for(;;)

两者都会挂起浏览器,但为什么空的 for 循环不会立即跳出自身?它的第二部分是空的,因此是虚假的。当第二部分为假时,for 循环停止并继续执行 for 循环之后的代码,这不是真的吗?

有人可以对此给出解释吗?

最佳答案

不,这不是真的。

参见:https://developer.mozilla.org/en/JavaScript/Reference/Statements/for

condition

An expression to be evaluated before each loop iteration. If this expression evaluates to true, statement is executed. This conditional test is optional. If omitted, the condition always evaluates to true. If the expression evaluates to false, execution skips to the first expression following the for construct.

我或许应该提供一个指向 ECMAScript 引用的链接,但我很确定它或多或少地陈述了同样的事情。

关于javascript - 空 for 循环 - for(;;),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4740979/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com