1 - First off some simple = ( assignment ) examples
To start off with comparisons it might be a good idea to start out with a few simple assignment examples. Expressions that make used of equality and identity operators will often be used to create a boolean value that will be used in a conditional statement. However they are also often used in expressions where some kind of value will end up being assigned to a variable also.
1.1 - basic assignment example
1.2 - Assignment and comparison expressions
Things will just get a little involved when it comes to using assignment with more complex expressions that involve comparisons, and maybe a conditional operator.
Simple enough for the most part however there are some things to be ware of, and there is also another operator === known as the identity operator. So be sure to read on if this is a subject that you still find a little confusing.
2.1 - The == operator preforms type conversion
The main difference between == and === is that == preforms type conversion. In the event that both operands that are used in the operation are not of the same type then type conversion is used to check if they equal each other when converted.
2.2 - Comparing objects
When comparing two objects the result is true when both operands are references to the same object. However any comparison of two objects that are different objects in memory will also result in false, even if they have the same set of values.
So when comparing objects the only thing of interest is if they are both the same object or not. If you want to find out if two objects have the same set of values or not you will want to loop over the contents, and compare each key. If you want to find out if they are both objects of the same class you could try the constructor property that would work in most cases.
2.3 - Two booleans
Same as with numbers and strings if a boolean is compared to a non boolean value type conversion is preformed. The resulting boolean value depends on the data type and the value of the type.
4 - Object.is, and lodash eq method
5 - Comparing to NAN
6 - Conclusion