obj for each code example
Example 1: object foreach
const obj = {
name: 'Jean-Luc Picard',
rank: 'Captain'
};
// Prints "name Jean-Luc Picard" followed by "rank Captain"
Object.keys(obj).forEach(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);
});