Last active
August 27, 2015 13:41
-
-
Save mgtitimoli/26d570fb39f6223f00e9 to your computer and use it in GitHub Desktop.
This file contains 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
// I'm using an IIFE since currently chrome console doesn't allow you to specify let statements in sloppy mode | |
(function test() { | |
"use strict"; | |
let obj = { key1: "value1", key2: "value2" }; | |
let swapped = Object | |
.keys(obj) | |
.reduce((res, key) => (res[obj[key]] = key, res), {}); | |
console.log(swapped); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment