js iterate over keys of object code example
Example 1: iterate key value object javascript
'use strict';
// ECMAScript 2017
const object = {'a': 1, 'b': 2, 'c' : 3};
for (const [key, value] of Object.entries(object)) {
console.log(key, value);
}
Example 2: loop over keys in object javascript
Object.keys(obj).forEach(function(key) {
console.log(key, obj[key]);
});