Understanding the JavaScript For...of Loop

Understanding the JavaScript For...of Loop

The for...of statement creates a loop that iterates over iterable objects. For...of loop was introduced in ES6 to be an alternative to both for..in and forEach() and supports the new iteration protocol. For..of lets you loop over data structures that are iterable such as Arrays, strings, Maps, Sets, and more.

[…]

JavaScript offers four known methods of terminating a loop execution namely: break, continue, return and throw. Let's look at an example:

[…]