编辑代码

const user = {id:1, name:"gowtham"};
const posts = { id:2,title:"my post", body:"demo"};
//扩展运算符合并
const result = {...user, ...posts};
console.log(result);

//使用Object.assign( )方法合并对象
console.log(Object.assign({}, user, posts));

 //合并三个对象
const comments = {comment: "super good"};
console.log(Object.assign({}, user, posts, comments));