1obj = {first_name : "Marty",
2 lovers: ["Jennifer Parker","Baines McFly"]
3 };
4let objClone = { ...obj }; // pass all key:value pairs from an object
5
6console.log(objClone)
7// { first_name: "Marty", lovers: ["Jennifer Parker", "Baines McFly"] }
1let obj1 = { foo: 'bar', x: 42 };
2let obj2 = { foo: 'baz', y: 13 };
3
4let clonedObj = { ...obj1 };
5// Object { foo: "bar", x: 42 }
6
7let mergedObj = { ...obj1, ...obj2 };
8// Object { foo: "baz", x: 42, y: 13 }