I have a data structure similar to:
var object = {
name: "a",
number: "1",
mission: ['a','b','c']
}
Now I want to update them into the database so I need to walk them.
I tried:
object.forEach(function(value, key, map){
console.log('value: ' + value + ', key: ' + key + ', map:' + map);
});
And then the console report an error: object.forEach is not a function
forEachshould be invoked on arrays not with an object. If you try on array of objects , it will workfor(var key in object) console.log(key, object);Object.entries(object).forEach(([key, value]) => console.log(`key: ${key}, value: ${value}`));With polyfills and transpilers this should run anywhere :pObject.entriesand (2) it is mainly about chunking.