for each loop with an object code example
Example 1: for each element in object
var obj = {
first: "John",
last: "Doe"
};
//
// Visit non-inherited enumerable keys
//
Object.keys(obj).forEach(function(key) {
console.log(key, obj[key]);
});
Example 2: for each of object
Object.keys(object).map(function(objectKey, index) {
var value = object[objectKey];
console.log(value);
});