aderaaij
11/14/2017 - 7:19 PM

ES6 - For Of loop

The for...of statement creates a loop iterating over iterable objects (including Array, Map, Set, String, TypedArray, arguments object and so on), invoking a custom iteration hook with statements to be executed for the value of each distinct property.


const heroes = ['The Hulk', 'Black Widow', 'Vision', 'Thor'];

for (const hero of heroes) {
    if(hero === 'Black Widow') {
        break;
    }
    console.log(hero);
}