두번째 매개변수에 들어간 객체가 첫째 매개변수에 병합된다.
const user = {
name: "mike",
age: 30,
};
const user2 = Object.assign({}, user);
user2.name = "tom";
console.log(user); //{name: "mike", age: 30}
console.log(user2); //{name: "tom", age: 30}
const user = {
name: "mike",
age: 30,
};
const result = Object.keys(user);
console.log(result); //["name", "age"]
const user = {
name: "mike",
age: 30,
};
const result = Object.keys(user);
console.log(result);
//[Array(2), Array(2)]
//(2) ["name", "mike"]
//(2) ["age", 30]
출처: https://www.youtube.com/watch?v=4_WLS9Lj6n4&t=5026s&ab_channel=%EC%BD%94%EB%94%A9%EC%95%99%EB%A7%88