Obect.assign(인자1, 인자2);
인자1에 인자2를 덮어씌운 객체를 반환한다.
const post = {
title : "test",
content : "Main Article"
}
const array = [1, 2, 3, 4, 5];
const clone = Object.assign({}, post);
const newArr = Object.assign([], array);
console.log(clone);
console.log(newArr);
'web > js' 카테고리의 다른 글
[js] for..in 과 for.of의 차이 (0) | 2023.07.07 |
---|---|
[JS] alert, prompt, comfirm (0) | 2023.06.22 |
[JS] 자료형 (0) | 2023.06.16 |