const user = {
name: "",
username: "",
phoneNumber: "",
email: "",
password: ""
};
const newUser = {
username: "ReedBarger",
email: "reed@gmail.com",
password: "mypassword"
};
console.log(Object.assign({}, user, newUser));
(1) Always start with an empty block {} so you don't overwrite 'user'.
(2) Don't forget that objects are passed as references and not values.
Top comments (0)