gpt4 book ai didi

javascript - 在 for 循环中使用现有变量

转载 作者:数据小太阳 更新时间:2023-10-29 05:55:48 25 4
gpt4 key购买 nike

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

otherVar = 3;

for ( otherVar > 0; otherVar-- )
{
stuff
}

最佳答案

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

var otherVar = 3;

for ( ; otherVar > 0; otherVar-- ) {
doStuff();
}

关于javascript - 在 for 循环中使用现有变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10713032/

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