- ES6 provides For…Of loop for iterate over a Array Element.
- The For…Of loop can be used to iterate over Array,arguments,Map and Set objects.
- In this demo, “We will learn to used For…Of loop to iterate over an array”.
- The following code contains a array named fruitList containing many fruit names.A For…Of loop is used to iterate over the fruitList array.
var fruitList = ["Apple","Orange","Mango"]; for (var aFruit of fruitList) { console.log("Fruit Name: "+aFruit); }
- The output of the previous code can be found in the following JSBIN link.