Please read carefully the question, this is not a duplicate of:
- ECMAScript 6 arrow function that returns an object
- javascript cannot map array of objects with nested values
- map function for objects (instead of arrays)
- Loop through an array in JavaScript
- map function for objects (instead of arrays)
- Loop through an array in JavaScript
Let's consider the following array of object:
var obj = [{ 'key1' : 'value1' }, { 'key2' : 'value2' }];
I would like to map the array to get keys and values for each object. Something like:
obj.map((key, val) => console.log(key, val));
I already try many stuff like Object.entries(obj)
but it always results in complicated solution with many brackets like Object.entries(obj)[0][1]
Is there a simple, nice and efficient way to map an array of object? Note I need key and value for each object