Toggle values into and out of an array in Javascript

前端 未结 4 959
臣服心动
臣服心动 2021-02-19 05:08

I want to have a simple array of values, ie

var simpleArray = [\"SE1\",\"SE2\",\"SE3\"];

I want to check this array when an action happens (a c

4条回答
  •  执念已碎
    2021-02-19 05:20

    extremely compact lodash version, using xor function, which is used to create a new array of values found only in one array and not the other

    xor(array, [valueYouWantToToggle])
    

提交回复
热议问题