Created
May 25, 2016 01:38
-
-
Save preco21/ffba292b66d9066f9a1e8b5c04c1046c to your computer and use it in GitHub Desktop.
Iterate over object key values
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
// ES2015 | |
for (const key of Object.keys(obj)) { | |
console.log(key); // key | |
console.log(obj[key]); // value | |
} | |
// ES2016 | |
for (const value of Object.vaules(obj)) { | |
console.log(value); // value | |
} | |
// ES2016 | |
for (const [key, value] of Object.entries(obj)) { | |
console.log(key); // key | |
console.log(value); // value | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment