How to iterate a Javascript Object
In many cases, we want to iterate over an Object for it's keys and respective values.
var obj = {
name:"John Doe",
age:23,
sex:"Male"
};
Object.entries(obj).forEach(([key,value])=>{
// console.log(key);
// console.log(value);
console.log(`KEY - ${key} | VALUE - ${value}`)
});
/*
KEY - name | VALUE - John Doe
KEY - age | VALUE - 23
KEY - sex | VALUE - Male
*/