DEV Community

Discussion on: Simplest way to compare two numbers array in JS

Collapse
 
tamusjroyce profile image
tamusjroyce

Check the length first. That is the simplest way to tell they may not be equivalent. You have also just sorted the original array1 and array2. ‘[…array2].sort()’ would be better.

array1.length === array2.length && array1.some???