pablocattaneo
4/12/2019 - 7:02 PM

How check if two array contains same elements in JavaScript?

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)));