Optional
use xor instead
If the item matching the condition already exists in the list it will be removed. If it does not it will be added.
Mutates the array
const gods = ['ra', 'zeus', 'loki']toggleInPlace(gods, 'ra') // => [zeus, loki]const gods = ['zeus', 'loki']toggleInPlace(gods, 'ra') // => [zeus, loki, ra] Copy
const gods = ['ra', 'zeus', 'loki']toggleInPlace(gods, 'ra') // => [zeus, loki]const gods = ['zeus', 'loki']toggleInPlace(gods, 'ra') // => [zeus, loki, ra]
Deprecated
use xor instead
Description
If the item matching the condition already exists in the list it will be removed. If it does not it will be added.
Remarks
Mutates the array
Example