I know I can do it using loops, but I’m trying to find an elegant way of doing this:
I have two arrays:
var array1 = [['a', 'b'], ['b', 'c']];
var array2 = [['b', 'c'], ['a', 'b']];
I want to use lodash
to confirm that the above two arrays are the same. By ‘the same’ I mean that there is no item in array1
that is not contained in array2
.
In terms of checking equality between these items:
['a', 'b'] == ['b', 'a']
or
['a', 'b'] == ['a', 'b']
Both work since the letters will always be in order.