I have an array of objects with the following format
var obj = [{
"a": 1
}, {
"b": 2
}, {
"c": 3
}];
Would want to fetch keys and values out of each object separately inside this array of objects into a new array
Something like this:
[{"key:"a","val:"1"],{"key":"b","val":"2"},{"key": "c","val":"3"]}
Have tried the following but it is not working :
var obj = [{
"a": 1
}, {
"b": 2
}, {
"c": 3
}];
const result = obj.map(value => Object.keys(value)[0]);
console.log(result);