DEV Community

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

Collapse
 
planet_cbx profile image
Charlène Bonnardeaux

I don't think that's a good practice, only because two arrays may contain the same thing but not in the same order... I would tend to just iterate on one and do a comparison with each of the values

Collapse
 
blackr1234 profile image
blackr1234

If order matters, don't sort them before converting to strings. Yeah of course you could loop them, or use utility libraries.