If I asked you, "What separates these two arrays: ['a'] and ['a', 'b']?" your answer would be 'b', correct?
I'm curious why underscore doesn't automatically provide bidirectional diff functionality. How can we use other methods to achieve this result?
var x = ['js-email'],
y = ['js-email', 'form-group'],
z = _.difference(x, y), // outcome: []
w = _.difference(y, x); // outcome: ["form-group"]
Check out this example on JSFiddle.
To clarify, I want the difference between the arrays to always be ['form-group']
, regardless of their order.