对象和对象直接利用传播操作符(…)进行传播使用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
var user={
name:"hyh",
age:99,
link:"http://www.baidu.com",
addess:"北京市"
}
//ES6解构
//对象传播操作符...
var{name,age,...user1}=user;
//解构出name和age属性
console.log(name);
console.log(age );
//利用对象传播操作符....将user对象中未解构出的属性传播给user1对象
console.log(user1);
//{link: "http://www.baidu.com", addess: "北京市"}
//addess: "北京市"
//link: "http://www.baidu.com"
//user1对象可以调用传播过来的属性,不能调用前面已经解构出的属性
console.log(user1.addess);
console.log(user1.link);
</script>
</head>
<body>
</body>
</html>