Closed fenekku closed 6 years ago
The == operator compares objects by identity
Note the word objects. For objects, ==
and ===
do the same thing (compare by identity). For values in general, they don't.
Thanks for bringing my attention to the use of objects there. I think "identity" was what really confused me though and so I made a pull request to actually use that word in the section about object identity. I also added in what you just said: ==
and ===
both compare by identity for objects. Hopefully that helps others? 😅
Thanks!
I hope attached patch makes this paragraph easier to read
Sorry about the delay. Yes this is clearer! I will close this issue. Thanks! :+1:
Hi,
I really like the book, but I was confused by the following sentences when reading through the Deep Comparison exercise:
and later
So, should I use
==
or===
to compare by "identity"? I also ask because I don't know what "identity" means in this context. The only 2 times the term is used on this page is in those sentences. From chapter 1,===
is used to compare precise equality (without type coercion). Is this identity?Thanks for the great resource!