In order to facilitate debugging, wrote a page is not logged in, Debug mode automatic login function, found that there is a variable i initialized to it to assign a string, but in the use of the time to find it turned false, good magic. After careful examination of the reference, it is found that a judgment condition is less than an equal sign. The JS code is as follows:
var ssessionkey = "Test_key";
if (Ssessionkey=Undefined | | Ssessionkey = = null) {
Console.error ("The Ssessionkey is null.");
Return
} console.info (Ssessionkey);//1 finally found that the 1 print will be false, carefully examine the discovery of the judgment ssessionkey less write an equal sign, resulting in an assignment symbol. Then why does it turn false? Speculation is related to the precedence of symbolic operations in JavaScript, and the precedence of the assignment operator is lower than the seek or operator, so the above judgment is equivalent to the following expression: if (Ssessionkey = (undefined | | ssessionkey = = NULL ) {} "Ssessionkey = = NULL" is the false,undefined judgment is also false, so the last assignment to Ssessionkey is a false. The final print is also false.
Parsing a string variable in JavaScript that suddenly turns false