What does the “==” do exactly?
“55” == “55”
55 == 55
“55” == 55
How is “===” any different from “==”?
“55” === “55”
55 === 55
“55” === 55
For example, this means that if you have the numbers 55 and “55” and try comparing them with the “===” operator that it will not only compare the contents of the two data or variables you pass to it, it will also compare the typeof variable or data it is. In this case, it would return false, because a string is not the same data type as an integer.
How can I compare == vs. === on my own?
Answer: Learn Chrome’s DevTools! DevTools (also known as Web Inspector) is a web developer’s best friend. They allow you to edit any website locally in real time. And they allow you to use their console feature to perform logic tests, write simple functions and much more. Check out this Chrome’s DevTools Tutorial if you’d like to learn more.
- Open DevTools by pressing down Command+Shift+I (Mac) or by right-clicking anywhere on the screen and selecting “Inspect”.
What about the != operator and !==?
You can also compare if something is “!=” (not equal to) something else, and if something is “!==” (strictly not equal to) something else.
When testing if “55” !== 55 with the !== operator, the answer returned will be true because the string “55” is not strictly equal to the integer 55.