Skip to content

Instantly share code, notes, and snippets.

@devhero
Last active May 12, 2022 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devhero/e2436c4ba5973bac5b219cafb7c6c873 to your computer and use it in GitHub Desktop.
Save devhero/e2436c4ba5973bac5b219cafb7c6c873 to your computer and use it in GitHub Desktop.
js iterate through an object #js
// iterate through
Object.entries(myObject).forEach(([key, value]) => {
console.log(`${key}: ${value}`)
});
// return a new array
Object.entries(myObject).map(([key, value]) => {
return {
key,
value
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment