Empty for loop - for(;;)

前端 未结 4 1853
青春惊慌失措
青春惊慌失措 2020-12-01 13:06

I was exploring the Google Closure Compiler, and one thing I noticed was that it converts while(true) into for(;;).

Both do hang the browse

4条回答
  •  渐次进展
    2020-12-01 13:41

    There is evaluation algorothm of for loop in Standard ECMA-262 script that says there are only two situations in which loop will end:

    1. break statement
    2. value of middle statement equal to false, but only if this statement is present, so it doesnt have to be necessary valuated as true (probably in mozilla js engine it is).

提交回复
热议问题