toggle an element in array javascript code example
Example: toggle an element in array javascript
//If you can use lodash library
let array=[1,2,3]
_.xor(array, [2]) //returns [1,3]
_.xor(array, [4]) //returns [1,2,3,4]
//If you can use lodash library
let array=[1,2,3]
_.xor(array, [2]) //returns [1,3]
_.xor(array, [4]) //returns [1,2,3,4]