When comparing the equality of non-primitives, Javascript checks equality by equality of reference - that is, do both objects being tested refer to the same object in memory?
In this case, they do not - .map
returns a new object, and running .map
on the same array two different times will return two different references - regardless of the computations done while mapping.
To sum it all up:
v === v
is true because v refers to the same object in memory
[1,2,3,4,5] === [1,2,3,4,5]
is false because both arrays are different objects in memory (i.e. reference is compared, not values)
.map
will always return a new instance of an array - so the result cannot be equal to another .map
statement