DEV Community

loading...

Discussion on: How to compare two arrays in javascript?

Collapse
pestrinmarco profile image
Marco Pestrin Author

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