withArrayItemconstant
withArrayItem: <T>(items: PossibleArray<T>, add: T) => ImmutableArray<T>
| Return | |
|---|---|
unknown | A new array including the added item, or the same array if nothing changed. |
Add an item to an array (immutably) and return a new array with that item (or the same array if no changes were made).
Examples
withArrayItem([1, 2], 3); // [1, 2, 3]