iterate object js
let obj = {
key1: "value1",
key2: "value2",
key3: "value3",
key4: "value4",
}
Object.entries(obj).forEach(([key, value]) => {
console.log(key, value);
});var person={
first_name:"johnny",
last_name: "johnson",
phone:"703-3424-1111"
};
for (var property in person) {
console.log(property,":",person[property]);
}var obj = {
first: "John",
last: "Doe"
};
//
// Visit non-inherited enumerable keys
//
Object.keys(obj).forEach(function(key) {
console.log(key, obj[key]);
});const object = {a: 1, b: 2, c: 3};
for (const property in object) {
console.log(`${property}: ${object[property]}`);
}Object.entries(obj).forEach(([key, value]) => {
console.log(key, value);
});for (let key in yourobject) {
if (yourobject.hasOwnProperty(key)) {
console.log(key, yourobject[key]);
}
}