정적 메서드(static method)
Object.assign()
메서드는 열거할 수 있는 하나 이상의 출처 객체로부터 대상 객체로 속성을 복사할 때 사용한다. 대상객체를 반환한다.
const target = { a: 1, b: 2 };
const source = { b: 4, c: 5 };
***const returnedTarget = Object.assign(target, source);***
console.log(target);
// expected output: Object { a: 1, b: 4, c: 5 }
console.log(returnedTarget);
// expected output: Object { a: 1, b: 4, c: 5 }
const user = {
name: 'mooooburg',
age: 39,
email: '[email protected]',
}
***const keys = Object.keys(user)
console.log(keys) // ['name', 'age', 'email]
console.log(user['email']) // [email protected]***
***const values = keys.map(key => user[key])
console.log(values] // ['mooooburg', 39, '[email protected]']***