DEV Community

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

Collapse
 
suckup_de profile image
Lars Moelleken • Edited

Last time I needed to compare sommeting in JS I used "JSON.stringify" but its still a hack. What is the correct way to do it nowadays? 🤔

Collapse
 
0shuvo0 profile image
Shuvo

Writing an algorithm with loop and recursion if needed

Thread Thread
 
ksengine profile image
Kavindu Santhusa

Extractly

Collapse
 
valeriavg profile image
Valeria

There is no general right or wrong as it depends on a particular use case, but if you want an optimal solution that would handle most of the cases it'll probably be a recursive iterator over indices with early return.