var arr = ['a', 'b', 'c'];
// 1
for (var index = 0; index < arr.length; index++)
{
console.log(arr[index]);
}
// 2 ES5
arr.forEach(function (value) {
console.log(value);
});
// 3 for-in work the array or string or other collections that will return an index
for (var index in arr)
{
console.log(arr[index]);
}
// 4 ES6
for (var value of arr)
{
console.log(value);
}
// the for-of also works on strings,set, map
var str = "hello boy";
for (var s of str)
{
console.log(s);
}
var words = ['just', 'do', 'it', 'it'];
var uniqueWords = new Set(words);
// console.log(uniqueWords);
for (var word of uniqueWords)
{
console.log(word);
}
var MyMap = new Map();
for (var index in Map)
{
}