Javascript does not allow comparision of arrays using includes
?
See this example:
let x = [[1,2], [3,4]]
let y = x[0]
let z = [1,2]
console.log(y,z)
// Output: [ 1, 2 ] [ 1, 2 ]
console.log(x.includes(y), x.includes(z))
// Output: true false
I would like to have x.includes(z)
to be true
.
I was made aware of the qurestion check-if-an-array-contains-any-element-of-another-array-in-javascript by the comments, but it does not answer my question as I want to check if the array has exactly the same elements using includes
not only some.
Moreover, this question how-to-compare-arrays-in-javascript does not explain why includes
does not work. It tells how to do it, which is not the point of my question.