代码部分
<script> var geyao = { name: "geyao", age: "18" } var geyaoTest = { ...geyao, sex: "男" } console.log(geyaoTest, "geyaoTest") var fangfang = ["fangfang", "花花"] var fangfangTest = [...fangfang, "康康"] console.log(fangfangTest, "fangfangTest") //Object { name: "geyao", age: "18", sex: "男" } //Array(3) [ "fangfang", "花花", "康康" ] fangfangTest
运行结果
//Object { name: "geyao", age: "18", sex: "男" } //Array(3) [ "fangfang", "花花", "康康" ]