Version: v0.5.1 - Beta.  We welcome contributors & feedback.  THanks!

Map.reverse

reverse()

Description

Flip each key/value pair so that the values is the key, and the key is the value.

If duplicate keys are created, the latest one will overwrite all previous keys.

let map = { a: 1, b: 2, c: 1 };
let flipped = map.reverse();

print(flipped);
//= { 1: 'c', 2: 'b' }