var a = {a:1,b:2} var b = {a:2,b:3} [a,b].forEach(key => { console.log(key) })
Maybe the expression is not very clear. Please add a picture
[a, b].forEach(key => { console.log(JSON.stringify(key)) })
var a = {a:1,b:2}; var b = {a:2,b:3}; [a,b].forEach(obj => { for (key in obj) { console.log(obj[key]); } })
obj = { a: {}, b: {} } for(key in obj) { console.log(key) }
I still don’t quite understand the result you want
[a,b].forEach(obj => { for(key in obj) { console.log(key) } })
[a, b].forEach( (v) => console.log(v)); // { a: 1, b: 2 } // { a: 2, b: 3 } [a, b].forEach( (v) => { for(key in v) { console.log(key) } }); // a // b // a // b [a, b].forEach( (v) => { var {a, b} = v; console.log(a, b); }); // 1 2 // 2 3
That’s it - output a:1 b:2 a:2 b:3
[a, b].forEach(el => { for (let key in el) { console.log(`${key}:${el[key]}`) } });
I still don’t quite understand the result you want
That’s it - output a:1 b:2 a:2 b:3