9-2、区分剩余参数和展开运算符

112 阅读1分钟
    // 1.根本区别

    // 展开运算符
    // [3, 1, 2] -> 3, 1, 2

    // 剩余参数
    // 3, 1, 2 -> [3, 1, 2]

    // 2.区分剩余参数和展开运算符
    // const add = (...args) => {
    // console.log(args);
    // console.log(...args);
    // };
    // add(1, 2, 3)
    // console.log([...[1, 2, 3], 4]);
</script>