码迷,mamicode.com
首页 > 其他好文 > 详细

16-4-练习

时间:2019-09-07 13:33:38      阅读:94      评论:0      收藏:0      [点我收藏+]

标签:ros   自己   一个   alert   fine   html   rip   doc   ==   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body {
            font-family: "Microsoft YaHei", serif;
        }

        body, dl, dd, p, h1, h2, h3, h4, h5, h6 {
            margin: 0;
        }

        ol, ul, li {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        img {
            border: none
        }
    </style>
</head>
<body>

<script>
var x = 5;
a();
function a() {
    alert(x);
    var x=10;
}
alert(x);

    // 每执行到一个新的作用域,按照规则去解析
    // 1定义
    //var x;
    //function f() {...}
    // 2执行
    // x=5
    // a()====>新的作用域
    //         1定义
    //             var x
    //         2执行(自己有就用自己的,自己没有就用父亲的)
    //             alert(x)  undefined
    //             x = 10-vue-router;
    // alert(x)  5


</script>
</body>
</html>

 

16-4-练习

标签:ros   自己   一个   alert   fine   html   rip   doc   ==   

原文地址:https://www.cnblogs.com/zhangyu666/p/11479765.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!