Skip to content

Function.zipToMap

github-actions[bot] edited this page Jun 17, 2026 · 20 revisions

umt / zipToMap

Function: zipToMap()

zipToMap<K, V>(keys, values): Map<K, V>

Defined in: Map/zipToMap.ts:12

Creates a Map from two arrays, using the first as keys and the second as values. Pairs are formed at corresponding positions; iteration stops at the shorter length, matching the behavior of zip. Duplicate keys keep the latest value.

Type Parameters

K

K

V

V

Parameters

keys

K[]

Array of keys

values

V[]

Array of values

Returns

Map<K, V>

Map pairing keys with values at the same index

Example

zipToMap(["a", "b"], [1, 2]); // Map { "a" => 1, "b" => 2 }
zipToMap(["a", "b", "c"], [1, 2]); // Map { "a" => 1, "b" => 2 }

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally