addArrayItem()function
addArrayItem(arr: MutableArray<T>, item: T): T
| Param | Type | |
|---|---|---|
arr | MutableArray<T> | The array to add to (modified in place). required |
item | T | The item to add. required |
| Return | |
|---|---|
T | The added item. |
Add an item to an array (by reference) and return the item.
- Skip items that already exist.
Examples
addArrayItem(arr, 3); // 3 (and `arr` now contains `3`)