I have 2 arrays of objects and I have to compare them, but the order of the objects does NOT matter . I cannot sort them because I will not have the names of their keys, because the functions must be shared. The only information I will have about the array is that both objects in the array have the same number of keys, and these keys have the same name. Thus, array1 must contain the same objects as array2.
var array1 = [{"key1":"Banana", "key2":"Yammy"}, {"key1":"Broccoli", "key2":"Ew"}];
var array2 = [{"key1":"Broccoli", "key2":"Ew"}, {"key1":"Banana", "key2":"Yammy"}];
In this example, array1 should be equal to array2. I tried using the chai method .eql()
, but that did not work.
source
share