const iterable = [0, 1, 2];
for (let i of iterable) {
    console.log(i);
}

Expected output:

0 1 2

The advantages from the for…of loop are:

Support of for…of in other collections

Strings

for…of will treat a string as a sequence of Unicode characters:

const string = "abc";
for (let chr of string) {
  console.log(chr);
}

Expected output:

a b c

Sets

for…of works on Set objects.

Note:

const names = ['bob', 'alejandro', 'zandra', 'anna', 'bob'];

const uniqueNames = new Set(names);

for (let name of uniqueNames) {
  console.log(name);
}

Expected output: