20-2-结构赋值

<!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>


//    //ES6定义变量的解构赋值
//
//    let a = 10-vue-router,
//        b = 20,
//        c = 30;
//
//
//    // 这两个是一样的
//    let [d,e,f] = [10-vue-router,20,30];

    // function fn() {
    //     let x = [];
    //     for (let i=0;i<5;i++){
    //         x[i] = i*i;
    //     }
    //     return x;
    // }
    //
    // let [a,b,c,d,e,] = fn()

    // let {a:x,b:y} = {a:10-vue-router,b:20};
    // console.log(x);
    // // x和y是变量名

    // let {x:x,y:y} = {a:10-vue-router,b:20};
    // console.log(x);
    // console.log(y);


    // let {x:a,y:b} = {y:10-vue-router,x:20};
    // console.log(a);
    // console.log(b);

    let {x,y} = {y:10,x:20};


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

猜你喜欢

转载自www.cnblogs.com/zhangyu666/p/11480073.html