javascript中声明的全局变量是window的属性,方法是window的方法

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <title>Document</title>
    7. </head>
    8. <body>
    9. <script>
    10. // javascript中声明的全局变量是window的属性,方法是window的方法
    11. var a = 10;
    12. function go(){
    13. console.log("hello world")
    14. }
    15. // onst window = {
    16. // a:10,
    17. // go:function(){
    18. // console.log("hello world")
    19. // }
    20. // }
    21. //console.log(window)
    22. // window.go()
    23. console.log(a);
    24. go();
    25. </script>
    26. </body>
    27. </html>