CodeStates/learning contents
Unit 9. [JS]์์ ์๋ฃํ๊ณผ ์ฐธ์กฐ ์๋ฃํ
Jieunny
2022. 12. 22. 15:13
๐ฃ ์์ ์๋ฃํ
โ๏ธ ๊ณ ์ ๋ ์ ์ฅ ๊ณต๊ฐ์ ์ฐจ์งํ๋ ๋ฐ์ดํฐ
โ๏ธ number, string, boolean, null, undefined
โ๏ธ stack ์ ์ ์ฅ
โ๏ธ ๋ณต์ฌ ํ ๊ฒฝ์ฐ ๊ธฐ์กด ๋ฐ์ดํฐ ๊ฐ์ด ๋ณํ์ง ์๋๋ค. (immutable)
โ๏ธ ๊ฐ ์์ฒด์ ๋ํ ๋ณ๊ฒฝ์ ๋ถ๊ฐ๋ฅ ํ์ง๋ง ๋ณ์์ ๋ค๋ฅธ ๋ฐ์ดํฐ๋ฅผ ํ ๋นํ ์๋ ์๋ค.
๐ฃ ์ฐธ์กฐ ์๋ฃํ
โ๏ธ ๋๋์ ๋ฐ์ดํฐ๋ฅผ ๋ค๋ฃจ๊ธฐ ์ ํฉ
โ๏ธ ๋ฐฐ์ด, ๊ฐ์ฒด, ํจ์
โ๏ธ heap์ ์ ์ฅ (๋ฐ์ดํฐ๊ฐ ๋ด๊ธด ์ ์ฅ์์ ์ฃผ์๋ฅผ ์ ์ฅํ๋ค.)
โฐ heap์ ๋์ ์ผ๋ก ๋ณํ๋ค.
โ๏ธ ๋ณต์ฌ ํ ๊ฒฝ์ฐ ์๋ณธ์ด ๋ฐ๋๋ค.
let first = [10, 20, 30, 40];
let second = first;
second[0] = 5;
โฐ first์ second๋ ๊ฐ์ ์ฃผ์๋ฅผ ๊ณต์ ํ๊ณ ์๋ค.
โฐ first[0] = 5 ์ด๋ค.
โฐ first === second ๋ true ์ด๋ค.