How to loop through the object properties

Looping through an array is easy but ever stuck in a situation where you would need to loop through an object key and value pair to perform some manipulation.

When looping through an array you would simply use map(), forEach() or a for loop.

Use Object.entries method:

But when it comes to object iteration you can use the Object.entries to generate an array with all it's key and value properties.

Then, the generated array can be used to loop using the normal array looping methods like below ;

    console.log("object property ->", prop);

    console.log("object property ->", prop);

for (const prop of Object.entries(obj)){
    console.log("object property ->",prop)