For example:
If (! MyVar01) alert ("error occurred ");
// This Code directly causes an exception because the variable myVar01 does not declare if ("undefined" = typeof myVar01) alert ("error occurred ");
// This will not cause exceptions.
Var myVar01; if (undefined = myVar01) alert ("error occurred ");
// This code runs if ("undefined" = typeof myVar01) alert ("error occurred") correctly ");
// The Code will also run correctly
Conclusion: We use the following method to ensure that if ("undefined" = typeof myVar01) alert ("error occurred") is foolproof ");
// The Code will also run correctly
Of course, judging the effectiveness of data is far more than that, and there is also a null judgment, whether the number is too large.
Practical application:
Downlm is not defined
If ("undefined "! = Typeof downlm ){
If (downlm = "soft "){
Document. write ('success ');
}
}