addArrayItem()function

addArrayItem(arr: MutableArray<T>, item: T): T
ParamType
arrMutableArray<T>
The array to add to (modified in place). required
itemT
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`)