20-4-结构默认值

<!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>
    // function fn(data) {
    //     let a = data.a;
    //     let b = data.b;
    //
    //     let c = data.c;
    //     // let c = data.c || 100;
    //     // 如果c没有就给100
    //     // 但是如果用三目是给0的话那么这句依然执行到底的
    //     // 这个时候就必须用判断执行
    //     if (c === undefined) {
    //         c = 100;
    //     }
    // }
    //
    // fn({a:10-vue-router,b:20,c:0});



    // 这个就比较方便了只有是data.c严格等于un的时候才会等于100
    // function fn(data) {
    //     // let {a,b,c=100} = data;
    //     // 下边是完整写法
    //     let {a:a,b:b,c:c=100} = data;
    //     console.log(a, b, c);
    // }
    // fn({a:10-vue-router,b:20,c:0});

    // function fn(data) {
    //     let {x:a,y:b,z:c=100} = data;
    //     console.log(a, b, c);
    // }
    // fn({x:10-vue-router,y:20});

    // let [a,b,c=10-vue-router] = [10-vue-router,20,30];
    // console.log(a, b, c);

    function f() {
        console.log(xx);
    }
    let [x=f()] = [1];

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

猜你喜欢

转载自www.cnblogs.com/zhangyu666/p/11480081.html
今日推荐