a = [1,2,3];
b = [[1,2,3],[4,5,6]];
Why is that in javascript a== b[0] return false?
Thank you
a = [1,2,3];
b = [[1,2,3],[4,5,6]];
Why is that in javascript a== b[0] return false?
Thank you
In javascript objects are compared by references.
That said: a references to objects are compared, not the objects' contents.
Thus, One object {} will never be equal to another {} even though their contents are equal.
var a = {},
b = {}; // not equal
Whereas if you create a variable by assigning another reference to it like:
var a = {},
b = a; // equal
then both variables would hold the same reference and would be equal.