How to loop through objects in javascript?

PHOTO EMBED

Sun Jul 25 2021 11:17:35 GMT+0000 (UTC)

Saved by @joannpav

const animals = {
    tiger: 1,

    cat: 2,

    monkey: 3,

    elephant: 4
};

// iterate over object values

Object.values(animals).forEach(val => console.log(val));

// 1
// 2
// 3
// 4
content_copyCOPY

https://flexiple.com/loop-through-object-javascript/