Why an object with the same key : value is not equal?

Tell us what’s happening:
I don’t understood why the result is not equal, except if comparing an object is not possible with the == operator
assert.notEqual({ value: 1 }, { value: 1 }, '== compares object references');

Can you give me more info ?


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Use the Double Equals to Assert Equality

Link to the challenge:

1 Like

This is exactly it. A Javascript variable holds one value. This works fine for primative data like numbers or boolean, but for complex stuff like objects and arrys, they are too big to fit into the variable. Instead, the variable holds the location in memory where the object is stored. In this case, two brand new objects won’t be stored in the same spot, so they won’t compare as equal.


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.