DEV Community

Discussion on: How to compare two arrays in javascript?

Collapse
 
pestrinmarco profile image
Marco Pestrin

the condition is > -1

Collapse
 
stereobooster profile image
stereobooster • Edited
x = [1,2]
y = [2,1]
x.every(item => y.indexOf(item) > -1)
// true
Enter fullscreen mode Exit fullscreen mode