I have this array of object:
let obj = [
{ "id_feed": 114, "date_upd": 1666808102 },
{ "id_feed": 115, "date_upd": 1666808102 },
{ "id_feed": 116, "date_upd": 1666808102 },
] ;
I want to get all the keys and value. Note: this keys can dynamic, it could be anything.
So to get this I am trying :
Object.keys( obj ).forEach( ( item ) => {
console.log( obj[item] )
})
But seems like doing wrong :(
Expected Output:
id_feed = 114
date_upd = 1666808102
id_feed = 115
date_upd = 1666808102
id_feed = 116
date_upd = 1666808102
obj.forEach(...).Object.keys( obj ),objis not an object, but an array.objin the question indicates thatobjis anArray(the naming seems to be counter-intuitive to the value). So, please try:console.log(...obj?.flatMap(ob => Object.entries(ob)?.map(([k, v]) => `${k} = ${v}`)));