JS
See the Pen thecodelog.com - ES6 For..Of Loop 1 by Deano (@deangilewicz) on CodePen.
A for..in loop, loops over the keys (indexes and any property or method added to the prototype) in an array whereas a for..of loop loops over the values in an array.
See the Pen thecodelog.com - ES6 For..Of Loop 2 by Deano (@deangilewicz) on CodePen.
The “hello” primitive string value is coerced to the String object wrapper equivalent, which is an iterable by default allowing for..of loop to do its thing.
A for..of loop can also be used with the arguments keyword in a function.
See the Pen thecodelog.com - ES6 For..Of Loop 3 by Deano (@deangilewicz) on CodePen.
With a for..of loop it can be prematurely stopped just like other loops, using break, continue, return (if in a function), and thrown exceptions.
See the Pen thecodelog.com - ES6 For..Of Loop 4 by Deano (@deangilewicz) on CodePen.
The for..of loop does not work with objects since it is not an iterable but you can use something like Object.keys() to produce an iterable.
See the Pen thecodelog.com - ES6 For..Of Loop 5 by Deano (@deangilewicz) on CodePen.