script - spread ์ฐ์ฐ์
javascript์์ ์คํ๋ ๋์ฐ์ฐ์๋ฅผ ์๋ค๋ฉด ๋ฐฐ์ด์ ์ฌ์ฉํ ๋ ๊ฐํธํ๊ฒ ์ฌ์ฉ ํ ์ ์์ด์ ์ข๋ค.
1.์ ์
์คํ๋ ๋ ์ฐ์ฐ์๋ ์์ ์ด ์ํ๋ ๊ฐ์ฒด๋ฅผ ๋ณต์ฌํด์ ๋ฃ๋ ๋ฐฉ๋ฒ์ด๋ค.
์ฌ์ฉ๋ฐฉ๋ฒ์ ์์ ... ์ ๋ถ์ด๋ฉด ๋๋ค.
2. ์ฝ๋
์ด๋ป๊ฒ ๋ณต์ฌํด์ ๋ฃ๋์ง๋ ์ง์ ์ฝ๋๋ฅผ ํ์ธํ๋ฉด์ ๋ณด๋ฉด ์ฝ๊ฒ ์ดํดํ ์ ์๋ค.
const student1 ={
name: '์ด'
};
const student2 = {
...student1,
name: '๊น',
age: 10
};
const student3 = {
...student2
name: '๋ฐ',
age:20,
hobby: 'game'
};
console.log(student1);
console.log(student2);
console.log(student3);
์์ ์ฝ๋๋ฅผ ํด์์ ํด์ํ์๋ฉด
student2์์ ...student1๋ฅผ ์์ฑํ๋ฏ๋ก์จ ์คํ๋ ๋ ์ฐ์ฐ์๋ฅผ ์ฌ์ฉํ์๋ค.
๊ทธ๋์ ์ถ๋ ฅ์ ํ์์ ๋ student1 ๊ฐ์ฒด๋ค๊ณผ ํจ๊ป ์ถ๋ ฅ์ด ๋๋ค.
student3๋ ๋ง์ฐฌ๊ฐ์ง๋ก ...student2์ ์ผ๊ธฐ๋๋ฌธ์ ์ถ๋ ฅ์ ํ ๋ student2 ๊ฐ์ฒด๋ค๋ ํจ๊ป ์ถ๋ ฅ์ด ๋๋ค.
Author And Source
์ด ๋ฌธ์ ์ ๊ดํ์ฌ(script - spread ์ฐ์ฐ์), ์ฐ๋ฆฌ๋ ์ด๊ณณ์์ ๋ ๋ง์ ์๋ฃ๋ฅผ ๋ฐ๊ฒฌํ๊ณ ๋งํฌ๋ฅผ ํด๋ฆญํ์ฌ ๋ณด์๋ค https://velog.io/@zlor26/Javascript-spread-์ฐ์ฐ์์ ์ ๊ท์: ์์์ ์ ๋ณด๊ฐ ์์์ URL์ ํฌํจ๋์ด ์์ผ๋ฉฐ ์ ์๊ถ์ ์์์ ์์ ์ ๋๋ค.
์ฐ์ํ ๊ฐ๋ฐ์ ์ฝํ
์ธ ๋ฐ๊ฒฌ์ ์ ๋
(Collection and Share based on the CC Protocol.)
์ข์ ์นํ์ด์ง ์ฆ๊ฒจ์ฐพ๊ธฐ
๊ฐ๋ฐ์ ์ฐ์ ์ฌ์ดํธ ์์ง
๊ฐ๋ฐ์๊ฐ ์์์ผ ํ ํ์ ์ฌ์ดํธ 100์ ์ถ์ฒ ์ฐ๋ฆฌ๋ ๋น์ ์ ์ํด 100๊ฐ์ ์์ฃผ ์ฌ์ฉํ๋ ๊ฐ๋ฐ์ ํ์ต ์ฌ์ดํธ๋ฅผ ์ ๋ฆฌํ์ต๋๋ค