美文网首页
解构赋值

解构赋值

作者: asmuzi | 来源:发表于2018-12-21 13:28 被阅读0次
    <!DOCTYPE html>
    <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>Document</title>
        <script>
            let [a, b, c] = [12, 5, 8];
    
            console.log(a);
            console.log(b);
            console.log(c);
        </script>
    </head>
    
    <body>
    
    </body>
    
    </html>
    
    tip:解构赋值两边的结构必须一致
    <!DOCTYPE html>
    <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>Document</title>
        <script>
            // let [a, b, c] = [12, 5, 8];
    
            let { a, b, c } = { a: 12, b: 5, c: 8 };
    
            console.log(a);
            console.log(b);
            console.log(c);
        </script>
    </head>
    
    <body>
    
    </body>
    
    </html>
    

    相关文章

      网友评论

          本文标题:解构赋值

          本文链接:https://www.haomeiwen.com/subject/reumkqtx.html