[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [setOrPush](./js-utils.setorpush.md) ## setOrPush() function Set a map key to a new array or push to the existing value. Signature: ```typescript export declare function setOrPush(map: Map>, key: TKey, val: TVal | ReadonlyArray): Map>; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | map | Map<TKey, ReadonlyArray<TVal>> | The destination map and source of existing values. | | key | TKey | The key to get and set. | | val | TVal \| ReadonlyArray<TVal> | The value to add. | Returns: Map<TKey, ReadonlyArray<TVal>>