Today, I saw situ's article in my blog. I saw this line of code if (typeof item = "string"). I saw three equal signs that I have never written before, maybe it's the reason why my JS technology is still in its infancy. I went to the Internet and checked some information online, saying that this is a fully equal sign.
In the past, the equal sign "=" has never been used in JS to use the equal symbol "= ". When the two operators only detect the equality of two objects, one executes the type conversion and the other does not convert. All equal to the symbol returns true only when the type is not converted.
Var sNum = "66 ";
Var iNum = 66;
Alert (sNum = iNum); // The output is true.
Alert (sNum === iNum); // The output is false.
When the first equals operator is compared, the sNum value "66" is converted to the numeric type, and then compared with the iNum, true is returned.
The second full equal sign comparison does not perform type conversion, so the string and number types cannot be true, and all return false
There is also a non-full equal sign and non-equal
Var sNum = "66 ";
Var iNum = 66;
Alert (sNum! = INum); // the return value is false.
Alert (sNum! === INum); // return true
The first operator is easy to understand. The operator converts sNum to the numeric type. After converting to the numeric type, the two values are equal and false is returned.
The second operator does not convert the sNum type. Therefore, sNum is not equal to iNum. Therefore, true is returned.
This is my learning notes.