Directly from the node REPL:
> d1 = {key : "value"}
{ key: 'value' }
> d2 = {"key" : "value"}
{ key: 'value' }
> d1 == d2
false
Why is d1 different from d2 ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It isn’t, you’d get the same result if you just repeated the first line with
d2instead ofd1. However, the two objects you’re creating are different objects, and so they are not==.==with object references checks to see if the two operands refer to the same object (Section 11.9.3 of the spec). What you have there is two objects which both have a property calledkeywith the value “value”.