javascript loop throug object code example
Example 1: loop through object javascript
for (var property in object) {
if (object.hasOwnProperty(property)) {
// Do things here
}
}
Example 2: js object for each
const obj = {
a: 1,
b: 2,
c: 3
};
for (let key in obj) {
console.log(key + " = " + obj[key]);
}
// Ausgabe:
// "a = 1"
// "b = 2"
// "c = 3"