Java Basic Tutorial
Java Advance Tutorial
A for
loop is used to run a block of code repeatedly for a specified number of times, based on a condition. It is one of the most common control structures in JavaScript.
for (initialization; condition; increment/decrement) { // Code to execute }
false
to terminate the loop).Try it yourself
Try it yourself
The for-each loop is used to iterate over arrays or collections without using an index. It's simpler and avoids potential errors with index handling.
for (dataType variable : arrayOrCollection) { // Code to execute }
Try it yourself