Last active
July 14, 2017 02:14
-
-
Save charpeni/c12e5a1a7c799f2202773597b512cfe7 to your computer and use it in GitHub Desktop.
ES8 Object.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
const translations = { | |
en: { | |
home: "Home", | |
greeting: "Welcome", | |
}, | |
fr: { | |
home: "Accueil", | |
greeting: "Bienvenue", | |
}, | |
}; | |
Object.keys(translations).forEach((key) => { | |
console.log(key); // "en" | |
// "fr" | |
}); | |
Object.values(translations).forEach((value) => { | |
console.log(value); // "{ home: "Home", greeting: "Welcome" }" | |
// "{ home: "Accueil, greeting: "Bienvenue" }" | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment