[英]Semicolon is optional in JavaScript. However, could I omit the semicolons in the for loop?
Semicolon is optional in JavaScript. JavaScript 中分号是可选的。 However, could I omit the semicolons in the for loop?
但是,我可以省略 for 循环中的分号吗? For example:
例如:
for (let i = 0 i < arr.length i++) {
console.log(arr[i])
}
I'm new to JavaScript, I'm coming from C and C++ where semicolon is a must.我是 JavaScript 的新手,我来自 C 和 C++,其中分号是必须的。
Semicolons are used when you have more than one statements.当您有多个语句时使用分号。 If you have only one statement in for loop, you don't need to put semicolon.
如果 for 循环中只有一条语句,则不需要放置分号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.