Skip to content

Instantly share code, notes, and snippets.

@charpeni
Last active July 14, 2017 02:14
Show Gist options
  • Save charpeni/c12e5a1a7c799f2202773597b512cfe7 to your computer and use it in GitHub Desktop.
Save charpeni/c12e5a1a7c799f2202773597b512cfe7 to your computer and use it in GitHub Desktop.
ES8 Object.values
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