在for循环中使用现有变量

Ess*_*ial 6 javascript loops for-loop

是否有可能从for循环中省略变量赋值并执行类似的操作......?

otherVar = 3;

for ( otherVar > 0; otherVar-- )
{
    stuff
}
Run Code Online (Sandbox Code Playgroud)

jah*_*roy 11

是的,但你需要放入分号:

var otherVar = 3;

for ( ; otherVar > 0; otherVar-- ) {
    doStuff();
}
Run Code Online (Sandbox Code Playgroud)