1let obj = {
2 key1: "value1",
3 key2: "value2",
4 key3: "value3",
5 key4: "value4",
6}
7Object.entries(obj).forEach(([key, value]) => {
8 console.log(key, value);
9});
1var person={
2 first_name:"johnny",
3 last_name: "johnson",
4 phone:"703-3424-1111"
5};
6for (var property in person) {
7 console.log(property,":",person[property]);
8}
1const obj = { 0: 'a', 1: 'b', 2: 'c' };
2console.log(Object.entries(obj)); // => [ ['0', 'a'], ['1', 'b'], ['2', 'c'] ]
3
4Object.entries(obj).forEach((key, value) => {
5 console.log(key + ' ' + value);
6});
1let obj = {
2 key1: "value1",
3 key2: "value2",
4 key3: "value3"
5}
6for (let key in obj) {
7 let value = obj[key];
8 console.log(key, value);
9}
10// key1 value1
11// key2 value2
12// key3 value3
13
1// For a functional one-liner
2Object.keys(pokemons).forEach(console.log);
3// Bulbasaur
4// Charmander
5// Squirtle
6// Pikachu