<!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);
//对象合并,后边的会覆盖前边的对象