You can iterate keys in an object using ES 6 like below.
let employe = {
name: 'Chaitanya',
eno: '1'
};
for (let [key, value] of Object.entries(employe)) {
console.log(`${key}: ${value}`);
}
or there is another way using forEach method
Object.entries(employe).forEach(([key, value]) => {
console.log(`${key}: ${value}`);
});
Object.enttries() got standardised in ECMAScript2017. Below is the browser support chart collected from MDN
Top comments (0)