Removes itemToToggle from the array if it is present; otherwise appends it. Useful for managing selection sets.
itemToToggle
The source array.
The item to toggle.
toggleArrayItem([1, 2, 3], 2) // => [1, 3]toggleArrayItem([1, 3], 2) // => [1, 3, 2] Copy
toggleArrayItem([1, 2, 3], 2) // => [1, 3]toggleArrayItem([1, 3], 2) // => [1, 3, 2]
Removes
itemToTogglefrom the array if it is present; otherwise appends it. Useful for managing selection sets.