Question: I have these two arrays: one is filled with information from an ajax request and another stores the buttons the user clicks on. I use this code (I filled with sample numbers):

```
var array1 = [2, 4];
var array2 = [4, 2]; //It cames from the user button clicks, so it might be disordered.
array1.sort(); //Sorts both Ajax and user info.
array2.sort();
if (array1==array2) {
    doSomething();
}else{
    doAnotherThing();
}

```

But it always gives `false`, even if the two arrays are the same, but with different name. (I checked this in Chrome's JS Console). So, is there any way I could know if these two arrays contain the same? Why is it giving `false`? How can I know which values in the first array are not in the second?

Answer: 
You can use `reduce` instead of loops to appear clever, but at the risk of having your fellow developers think of you as a smart-ass.

```
function isArrayContentSame(a, b) {
  if (Array.isArray(a) && Array.isArray(b) && a.length == b.length) {
    a = a.concat().sort()
    b = b.concat().sort()
    return a.reduce((acc,e,i) => acc && e === b[i], true)
  } else {
    return false;
  }
}

```
Here is my solution without sorting:

```js
function isDifferent(t1,t2)
{
    return ((t1.length !== t2.length) || t1.some(tag1 => !t2.some(t=>t===tag1)));
}

let a1=['t','','b','xx','i','p','i'];
let a2=['','o','xx','b','t','p','i'];

console.log("DIFFERENT=",isDifferent(a1,a2)); //false

a1=['a','c','d'];
a2=['a','c'];

console.log("DIFFERENT=",isDifferent(a1,a2)); //true

a1=['a','c','d'];
a2=['a','c','c'];

console.log("DIFFERENT=",isDifferent(a1,a2)); //true

a1=['a','b','c'];
a2=['c','b','a'];

console.log("DIFFERENT=",isDifferent(a1,a2)); //false
```