Skip to content

Instantly share code, notes, and snippets.

@AitorAlejandro
Created March 13, 2022 16:41
Show Gist options
  • Save AitorAlejandro/3a2cd2fb972a7e71d638756330fc084e to your computer and use it in GitHub Desktop.
Save AitorAlejandro/3a2cd2fb972a7e71d638756330fc084e to your computer and use it in GitHub Desktop.
Loop over an object to access both key and value
const obj = { id: 1, name: 'laptop', price: 1200 };
Object.entries(obj).forEach(([key, value]) => {
console.log(key, value);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment