Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pablocattaneo/fc97f81e469aaf88503c06035f76eef8 to your computer and use it in GitHub Desktop.
Save pablocattaneo/fc97f81e469aaf88503c06035f76eef8 to your computer and use it in GitHub Desktop.
How check if two array contains same elements in JavaScript? Source: https://stackoverflow.com/a/49218423/3599272
const A = [0, 1, 2],
B = [2, 1, 0],
C=[2, 1];
// A.every( e => B.includes(e) )
console.log(A.every(e => B.includes(e)));
console.log(A.every(e => C.includes(e)));
console.log(C.every(e => B.includes(e)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment