Skip to content

Instantly share code, notes, and snippets.

@neatshell
Created December 15, 2018 17:40
Show Gist options
  • Save neatshell/dab83830be308879f04eb2bb7d815aba to your computer and use it in GitHub Desktop.
Save neatshell/dab83830be308879f04eb2bb7d815aba to your computer and use it in GitHub Desktop.
// Swap keys with values of a javascript object
const swapKV = (object) => {
const ret = {};
for (let key in object) {
if (object.hasOwnProperty(key)) {
ret[object[key]] = key;
}
}
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment