Semicolon is optional in JavaScript. However, could I omit the semicolons in the for loop? 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.
Semicolon is optional in JavaScript. However, could I omit the semicolons in the for loop? 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.
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.