With Javascript, you cannot check if arrays are equal, but you can compare them as follows:
var arr1 = ['alcohol', 'soft', 'hot'], arr2 = ['apple', 'pear'], arr3 = ['soft', 'hot', 'alcohol']; function isSame(a1, a2){ return !(a1.sort() > a2.sort() || a1.sort() < a2.sort()); } console.log( isSame(arr1, arr2) );
sort put all the elements in the same order, and if both comparisons < and > are false, it means that both of them are the same.
Mic
source share