zipObject() function
keys と values を位置ごとにペアにしてオブジェクトを作ります。対応する値がないキーは undefined になり、余分な値は無視されます。
Signature:
typescript
function zipObject<K extends PropertyKey, V>(
keys: Iterable<K>,
values: Iterable<V>,
): Record<K, V>;Example
ts
zipObject(["a", "b"], [1, 2]); // { a: 1, b: 2 }
zipObject(["a", "b", "c"], [1, 2]); // { a: 1, b: 2, c: undefined }
zipObject(["a", "b"], [1, 2, 3]); // { a: 1, b: 2 }