+ 2
Identical Comparison Operators in JavaScript
I can't understand clearly that Identical Comparison Operators Such as: 1. === 2. !== What's the similarities or difference between IDENTICAL vs Normal { == vs === } or { != vs !== } Please answer me kindly, it'll be helpful not only for me but also others.... ~~Course Link~~ https://www.sololearn.com/learn/JavaScript/1132/
3 Respostas
+ 3
The Description column of table on 2nd slide explained it pretty well.
The identity operator `===` only evaluates to true when both operands are of the same type apart from having similar data (value). It is more strict because it compares the data equality and also type equality.
The equality operator `==` only checks for value (data) equality. But since Javascript is a dynamic typed language, there are times when two operands can be considered equal when they should not be.
TIPS:
It is recommended to get into habit of using the identity operator `===` over the equality ` operator ==` because the strict comparison of identity operator can give us a better conclusion.
More about these operators you can find here ...
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality
+ 1
In comparison
"===" It's mean equal to & equal value And "==" It's mean equal to
For example : 12 == 12
This is equal and this is true condition but is you write 12 == "12" then this is also true because this operation is only counting 10 number
But
We see this
For example : 12 === 12
This is equal because both sides are equal and same data type "number" ok and this is true condition.
But
If you write like this
12 === "natasha"
12 === "12"
Then this is not equal because 12 is number and natasha & "12" are string that's why this is false condition.