AI Features

Iterables and Looping

Let's have a look at the new type of loops the ES6 introduced.

The for of loop

ES6 introduced a new type of loop, the for of loop. Let’s take a look at how it is used.

 

Iterating over an array

Usually, we would iterate using the following method:

Javascript (babel-node)
var fruits = ['apple','banana','orange'];
for (var i = 0; i < fruits.length; i++){
console.log(fruits[i]);
}
// apple
// banana
// orange

This is a normal loop where at each iteration we increase the value of i ...

Ask