Arrays in ES6 have also gotten a little love. There are quite a few new methods available for use on them, and there is also a brand new way to iterate over arrays. In JavaScript there is something called Iterator Objects, these are things like arrays, strings and some things we haven’t looked at yet called Map and Set. In ES6 the for...of loop is a new construct that allows us to iterate over these objects.


The syntax for the for...of loop is very similar to that of the loop, but instead of looping through the keys of an object it will loop through the elements of the array.

Get hands-on with 1200+ tech skills courses.