toggleArrayItems()function

toggleArrayItems(items: PossibleArray<T>, ...toggle: T[]): ImmutableArray<T>
ParamType
itemsPossibleArray<T>
The array or iterable to toggle within. required
toggleT[]
The items to toggle (added if absent, removed if present). required
Return
ImmutableArray<T>
A new array with the items toggled, or the same array if nothing changed.

Toggle an item in and out of an array (immutably) and return a new array with or without the specified items (or the same array if no changes were made).

Examples

toggleArrayItems([1, 2], 2, 3); // [1, 3]