Skip to content

Instantly share code, notes, and snippets.

@shoaibmehedi7
Last active April 13, 2021 11:04
Show Gist options
  • Save shoaibmehedi7/970a90f2ca0c570a86a920a49ffb115f to your computer and use it in GitHub Desktop.
Save shoaibmehedi7/970a90f2ca0c570a86a920a49ffb115f to your computer and use it in GitHub Desktop.
// Simple way
const person = { name: "Shoaib", Age: 25, Gender: "Male" };
for (const property in person) {
console.log(`${property}: ${person[property]}`);
}
// Another way
const anotherPerson = {
Name: 'Shoaib',
Age: 25,
Gender:"Male"
};
for (const [key, value] of Object.entries(anotherPerson)) {
console.log(`${key}: ${value}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment