ES6-对象扩展运算符
<html> <head> <title>ES6-对象扩展运算符</title> </head> <body> <script> // 1、拷贝对象 { let person1 = { name: "Amy", age: 15 }; let someone = { ...person1 }; console.log(someone); //{name: "Amy", age: 15} console.log(person1 == someone);//false 只是做了属性赋值。还是2个对象 } console.log("----------------------拷贝对象:分割线-------------------------------"); // 1、合并对象 { let person1 = { name: "Amy" }; let someone = { age: 15 }; let ming={...person1,...someone}; console.log(ming); //输出{name: "Amy", age: 15} } </script> </body> </html>