结构赋值

 <html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>let和 var const</title>
</head>

<body>
    <button>按钮1</button>
    <button>按钮2</button>
    <button>按钮3</button>
    <button>按钮4</button>
    <button>按钮5</button>

<script>
                //01 只能在代码块中有效
                /*  {
                      const li = 'aa';
                      console.log(li)
                      const li = "cc"
                      console.log(li)
                  }*/
                //03  不能重复的申明
                //04 申明常量必须赋值
                /* let person = '张三',
                     age = 18,
                     sex = '男';
                 console.log(person)*/
                //02 对象结构赋值
                /* let [name, sex, age] = ['张三', '男', '18']
                 console.log(name, sex, age)*/
                /*     let {
                         name,
                         sex,
                         age,
                         fridends,
                         pet
                     } = {
                         name: '李四',
                         sex: '男',
                         age: 18,
                         fridends: ['张三', '王麻子'],
                         pet: {
                             name: '小花',
                             age: 19

                         }
                     }
                     console.log(name, sex, age, fridends, pet)*/
                //03 数组的结构赋值
                //   let [name, sex, age] = ['张三', '男', '18']
                // let [arr1, [arr2, arr3, arr4, [arr5, arr6]]] = [1, [1, 2, 4, [7, 8]]]
                // console.log(arr1, arr2, arr3, arr4, arr5, arr6, )
                //04 基本类型的结构赋值
                let [a, b, d, c, e] = '我是一只猫'
                console.log(a, b, d, c, e)
            </script>
</body>

</html>
每个你讨厌的现在,都有一个不努力的曾经
原文地址:https://www.cnblogs.com/yuanxiangguang/p/11307039.html