zoukankan      html  css  js  c++  java
  • es6--扩展运算符

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    
        <script>
            /**
             *扩展运算符
             *
             * */
            function show(...a) {
                console.log("a", a);
            }
            //收缩
            show(1, 2, 3, 4)
            //展开
            let arr = [1, 2, 3, 4];
            console.log("arr", ...arr);
            //剩余预算符
            function add(a, b, ...c) {
                console.log("add", a, b, c);
            }
    
            add(1, 2, 3, 4)
            //对象不可以
            // let obj = {
            //     a: 1,
            //     b: 2,
            //     c: 3
            // }
            // console.log("obj", ...obj);
    
            let arrb = [...arr];//复制数组
            //箭头函数没有arguments对象
            //箭头函数改变this的作用域
            //参数对象可以用...args
            //箭头函数不能当构造函数用,不能new
    
        </script>
    </head>
    
    <body>
    
    </body>
    
    </html>
    
    let obj1 = {
                name: "a",
                age: 1
            }
    
            let obj2 = {
                address: "吉林",
                name: "b"
    
            }
    
            let obj3 = { ...obj1, ...obj2 };
            console.log("obj3", obj3);
           //对象合并,后边的会覆盖前边的对象
  • 相关阅读:
    SpringBoot自定义HttpMessageConverter
    第一次使用Linux服务器所栽之坑
    入门Nginx
    HttpClient中的Timout
    SpringBoot启动
    SpringBoot注解
    百度2017春招笔试
    学习JUnit
    Mybatis中的@SelectKey注解
    PHP中MD5函数漏洞
  • 原文地址:https://www.cnblogs.com/jentary/p/13334611.html
Copyright © 2011-2022 走看看