I had a problem where I wanted to either remove an item from a list if it existed or add it to the list if it did not exist.
A use case for this might be selecting which day(s) of the week you want:
Behind the scenes, you might store this as a simple array:
You can add or remove days easily using the xor function in lodash, which, of course, only returns items in the list that exist in exactly one list:
Remember that the result of the .xor is a new array, so if you want to update the original array, you need to assign it to the result of .xor().