Because ==
(and ===
) test to see if two objects are the same object and not if they are identical objects.
Most test frameworks will include functions such as deepEqual
if you want to see if two objects are identical.
More Related Contents:
- JavaScript comparison operators: Identity vs. Equality
- Can I use chained comparison operator syntax? [duplicate]
- Which equals operator (== vs ===) should be used in JavaScript comparisons?
- What is the !! (not not) operator in JavaScript?
- Difference between == and === in JavaScript [duplicate]
- Is there a “null coalescing” operator in JavaScript?
- Question mark and colon in JavaScript
- What is the JavaScript >>> operator and how do you use it?
- JavaScript plus sign in front of function expression
- What does = +_ mean in JavaScript
- What do these JavaScript bitwise operators do?
- javascript i++ vs ++i [duplicate]
- What is the instanceof operator in JavaScript?
- How does !!~ (not not tilde/bang bang tilde) alter the result of a ‘contains/included’ Array method call?
- What is the JavaScript >>> operator and how do you use it?
- When to use the double not (!!) operator in JavaScript
- What does the || operator do?
- What does “somevar >> 0” mean?
- How does !!~ (not not tilde/bang bang tilde) alter the result of a ‘contains/included’ Array method call?
- && operator in Javascript
- What is “?:” notation in JavaScript?
- What is the difference between the = and == operators, and what is ===?
- JavaScript adding a string to a number
- spread operator vs array.concat()
- How can I round to whole numbers in JavaScript?
- Is it possible to create custom operators in JavaScript?
- JavaScript equality transitivity is weird
- What’s the difference between ( | ) and ( || )?
- Logical operator && and two strings in javascript
- What does “!” operator mean in javascript when it is used with a non-boolean variable?