Last active
May 12, 2022 06:50
-
-
Save devhero/e2436c4ba5973bac5b219cafb7c6c873 to your computer and use it in GitHub Desktop.
js iterate through an object #js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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