Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

Array iterating

We can loop through each and one of array's elements as we did with objects.

The only difference is the syntax since there are no keys to hold values.

There are two ways for iterating through all arrays properties (more with new functions but for now we stick to these two).

The classic for loop that uses a number for going through all indexes from 0 to array's length and the new for ... of loop which is equivalent to the for... in loop the normal objects have.

Both are doing the exact same thing. On the first case, the classic for loop, we use the increment number i from 0 to the length of the array and then we use this number to as the index in order to access a new element every iteration.

The ES6 for... of loop provides a more elegant syntax, as we don't have to specify an increment number and use it later as an index. We define a variable that represents the current element of the array at the given iteration. (similar to ES6 for...in for objects).

The two loops in line 49 and 53, they perform exactly the same task.