Created
March 13, 2022 16:41
-
-
Save AitorAlejandro/3a2cd2fb972a7e71d638756330fc084e to your computer and use it in GitHub Desktop.
Loop over an object to access both key and value
This file contains hidden or 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
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