es6 foreach on object code example
Example 1: es6 loop through object
for (var [key, value] of phoneBookMap) {
console.log(key + "'s phone number is: " + value);
}
Example 2: javascript foreach object
function logArrayElements(element, index, array) {
console.log('a[' + index + '] = ' + element)
}
// Notice that index 2 is skipped, since there is no item at
// that position in the array...
[2, 5, , 9].forEach(logArrayElements)
// logs:
// a[0] = 2
// a[1] = 5
// a[3] = 9