Iterating Arrays
Use loops to iterate an array in JavaScript.
We'll cover the following
In this lesson, we will see how loops iterate arrays, where iterate means accessing elements in the array one by one.
Iterating single-dimensional arrays
To iterate a single dimension array, we design a loop that will index each element and terminate when the end is reached. Take for example the following array:
var arr = [ 10, 25, 7, 100, 20 ];
To iterate it, we start off with the first element (index 0
) and end at the last element (index 4
).
Get hands-on with 1400+ tech skills courses.