源代码:
<html> <body onload = checkscope();> <script type = "text/javascript"> <!-- // Declare a global variable var myVar = "global"; function checkscope() { // Declare a local variable var myVar = "local"; document.write(myVar); } //--> </script> </body> </html>
运行结果:
程序员工具