<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript"> //js judges that variable initialization has three forms var x; if (x == null) { alert("x is null"); } if (typeof (x) == "undefined") { alert("x is undefined"); } //This form is recommended for judging variable initialization if(!x) { alert("not x"); //if(x){} Meaning: the variable has been initialized (the initialized means that the variable has been assigned), or the variable is not empty, or the variable is not undefined } </script> </head> <body> <a href="javascript:alert()" rel="external nofollow" >Get local time</a> </body> </html>