iterate over object values js code example
Example 1: javascript iterate object
let person={
first_name:"johnny",
last_name: "johnson",
phone:"703-3424-1111"
};
for (let i in person) {
let t = person[i]
console.log(i,":",t);
}
Example 2: javascript iterate over object keys and values
const object1 = {
a: 'somestring',
b: 42
};
for (let [key, value] of Object.entries(object1)) {
console.log(`${key}: ${value}`);
}
Example 3: javascript loop through object values
var myObj = {foo: "bar", baz: "baz"};
Object.values(myObj).map((val) => {
console.log(val);
})
Example 4: iterate over object javascript
Object.keys(pokemons).forEach(console.log);