Skip to main content

Entries from an Object

const event = {
name : "Steve",
email: "steve@test.com",
phone: "+18133060000"
}
const entries = Object.entries(event);

for (const [field, value] of entries) {
console.log(`${field}: ${value}`);
}

// expected output:
// "name: Steve"
// "email: steve@test.com"
// "phone: +18133060000"
// order is not guaranteed
const object1 = {
a: 'somestring',
b: 42
};

for (const [key, value] of Object.entries(object1)) {
console.log(`${key}: ${value}`);
}

// expected output:
// "a: somestring"
// "b: 42"
// order is not guaranteed