For objects like an array the equality operator does not check the values inside the array, it just checks whether the variables point to the same array. If you did the following:
let thisArray = [true, true, undefined, false, null];
let thatArray = thisArray;
Then your console.log would return true because both of those variables point to the same array. But when you use the spread operator to create a new array, it is making a new copy of the array and thus thatArray points to a completely different array even though the values in the array are exactly the same.
The analogy doesnât hold, unfortunately. They would have to be magic shopping bags that can contain the literal exact same item in both, which just ends up being more confusing. It works for empty shopping bags though
There are a few ways to do this depending on the values in the arrays. Definitely you could create a function that loops through both arrays comparing the values at each index. For simple arrays you could also convert them to a string using JSON.stringify and compare the string values.