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

ES6-解析赋值

时间:2020-05-21 23:57:57      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:ons   cal   html   har   str1   必须   device   ice   htm   

1.注意事项

  • A.左右两边结构必须一样
  • B.右边必须是个东西
  • C.声明和赋值不能分开(必须在一句话里完成)

2.代码如下

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>解构赋值</title>
    <script>
        let [a0, b0, c] = [12, 5, 8];
        let {d,e,f} = {d: 12,e: 21,f: 23};
        console.log(a0, b0, c);
        // 结果12,5,8
        console.log(d, e, f);
        // 结果12,21,23
        let [{a,b},[n1, n2, n3], num1, str1] = [{a: 1,b: 2},[12, 5, 8], 8, ‘cxzcv‘];
        let [json,arr, num2, str2] = [{a: 1, b: 2},[12, 5, 8], 7, ‘cx‘]
        console.log(a, b, n1, n2, n3, num1, str1);
        console.log(json, arr, num2, str2);
    </script>
</head>
<body>
</body>
</html>

ES6-解析赋值

标签:ons   cal   html   har   str1   必须   device   ice   htm   

原文地址:https://www.cnblogs.com/dongxuelove/p/12934321.html

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