const a1 = [ 10, 10, 10 ];
containsIdenticalValues(a1); // True
const a2 = [ { name:`Jane` }, { name:`John` } ];
containsIdenticalValues(a2); // True, even though object references are different
If we want to compare by value for objects that aren't readily converted to JSON, you need to provide a function:
containsIdenticalValues(someArray, (a, b) => {
return (a.eventType === b.eventType);
});
Returns true if array
is empty.
Returns true if all values in the array are the same. Uses value-based equality checking by default.