Skip to content
On this page

mapValues

ts
function mapValues<K, V>(
    map: Map<K, V>,
    cb: (value: V) => V
): Map<K, V>

Map the Map instance values into a new Map instance.

Example

ts
map.mapValues(
    new Map([
        ['a', 1],
        ['b', 'two'],
        ['c', true],
        [4, 'nada'],
    ]),
    value => value === true,
) /* Map {
    a -> false,
    b -> false,
    c -> true,
    4 -> false,
} */