ES6์์ ์ถ๊ฐ๋ ์๋ก์ด ์ฐ์ฐ์๋ก, ์์ด ๋ป ๊ทธ๋๋ก spread ์ฆ, ํผ์น๋ค์ ์๋ฏธ๋ฅผ ๊ฐ์ง๊ณ ์๊ณ
๊ฐ์ฒด๋ ๋ฐฐ์ด์ ํผ์ณ์ ๋์ด ํ ๋์ ์ฌ์ฉํ๋ค.
// ๋ฐฐ์ด ๋ณํฉ
const arr = [1, 2, 3, 4, 5]
console.log([...arr, 6])
// Expected Output : [1, 2, 3, 4, 5]
// ๋ฐฐ์ด ๋ณํฉ
const arr = [1, 2, 3, 4, 5]
const newArray = [...array];
console.log(newArray)
// Expected Output : [1, 2, 3, 4, 5]
const objA = [a:1, b:2, c:3, d:4, e:5]
const objB = { ...objA, b:7};
console.log(objB)
// Expected Output : [a:1, b:7, c:3, d:4, e:5]