In JavaScript, the syntax of the for loop is as follows:
index.tsx88 chars4 lines
Here's an example of using for loop in JavaScript to loop through an array:
index.tsx115 chars6 lines
This will output:
index.tsx20 chars4 lines
In the above example, i is the index variable that is initialized to 0 and it increments by 1 on each iteration until it is less than the length of the array (fruits.length). The console.log statement inside the loop is executed for each value of i, which prints the corresponding element of the array to the console.
gistlibby LogSnag