We can see this line of code if (typeofitem & quot; string & quot;). We can see three equal signs that have never been written before, maybe it's because my JS technology is still in its infancy, I checked some materials on the Internet and said that this is a fully equal sign. I used to use the equal sign "=" and never used the fully equal sign "=" in JS ". 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.
The Code is as follows:
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
The Code is as follows:
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.