<!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>
</head>
<body>
<script>
var student={
name:"Mike",
age:20,
school:"THU",
go:function(){
console.log("我骑着自行车去上课");
}
};
//对传播操作符...
//name和age已经被解构,对象student中的剩下属性都会传给student2
var {name,age,...student2}=student;
console.log(name);
console.log(age);
console.log(student2);
</script>
</body>
</html>
ES6 对象传播操作符
最新推荐文章于 2022-09-22 09:00:00 发布