Let say I have 2 arrays
firstArray = [1, 2, 3, 4, 5];
secondArray = [5, 4, 3, 2, 1];
I want to know if they contain the same elements, whi
Well there is an Array.sort() method in JavaScript, and for comparing the (sorted) arrays, I think it's best to check out this question, as it is has a really good answer.
Especially note that comparing arrays as strings (e.g. by JSON.stringify
) is a very bad idea, as values like "2,3"
might break such a check.