Now only special cases are mentioned:
1, a variable, such as N1=null
<script> varnull; Alert (N1); /* the value of the popup window is null */ if null) { /* If it is an if (N1) will not execute inside the function body * /alert ("popup Window"); } </script>
2, a variable, such as N1, does not assign a value
<script> var N1; Alert (N1); /* the value of the pop-up window is undefined */ if (typeof (n1) = = "undefined") {/* If it is an if (N1) or if (n1== "undefined") will not execute the inside function body * /alert ("Popup Window" ); } </script>
3, a variable, such as n1,n1= ""
<script> var n1 = ""; Alert (N1); /* the value of the popup window is empty (nothing is displayed, but the window is bounced) */ if (N1 = = "") { /* If it is an if (N1) will not execute inside the function body * /alert ("popup Window"); } </script>
4, a variable, such as n1,n1= ""
<script> var n1 = " "; Alert (N1); /* the value of the popup window is empty (nothing is displayed, but the window is bounced) */ if (N1) { /* If it is N1.trim (). length > 0 will not execute inside the function body * /alert ("popup Window"); } </script>
5, a variable, such as N1,N1=0,N2 not assigned value
<script> var n1 = 0; var n2; + N2); /* the value of the popup window is Nan */ if (IsNaN (n1 + n2)) { /* If an if (n1 + N2) will not execute inside the function body * /alert ("popup Window"); } </script>
6, for the above situation, in addition to n1= "" assignment is a number of spaces this special case, others can be judged by the following code
if (!N1)
Note: Because of the above cases, direct write if (n1) or if (N1+N2) does not directly execute the code in the function body, so it is also possible to write this.
Js--if condition judgment