In JavaScript , you can iterate through keys and values using these methods:
1.Using Object.keys()
const obj = { a: 1, b: 2, c: 3 };
Object.keys(obj).forEach(key => {
console.log(key, obj[key]); // key and value
});
2. Using Object.entries()
const obj = { a: 1, b: 2, c: 3 };
for (let [key, value] of Object.entries(obj)) {
console.log(key, value); // key and value
}