์ถ์ฒ : https://github.com/leonardomso/33-js-concepts
leonardomso/33-js-concepts
๐ 33 concepts every JavaScript developer should know. - leonardomso/33-js-concepts
github.com
2๋ฒ์งธ ํฌ์คํ ์ผ๋ก Primitive Types ์ ๋๋ค.
๊ฐ๋จํ ์ด์ผ๊ธฐํ์๋ฉด ์ฌ๋ฌ๊ฐ์ง ์๋ฃํ์ ๋ํ ๊ธฐ์ด์ ์ธ ์ด์ผ๊ธฐ ์ ๋๋ค.
string / number / boolean / null / undefined / NaN
string์ ๊ฒฝ์ฐ ๋ณดํต "" ๋ '' ์ผ๋ก ์๋ค๋ฅผ ๊ฐ์ธ๋ ํํ๋ก ์์ฑํ๋ฉฐ
์ด๊ฒ์ ์์ด์ ํ ๊ฒฝ์ฐ "hello' ์๋ฌ๊ฐ ๋ฐ์ํ๊ฒ ๋ฉ๋๋ค.
+ ์ซ์๋ boolean์ ํด๋นํ๋ true๋ฅผ "" ์์ ์ธ ๊ฒฝ์ฐ ๋น์ฐํ string์ผ๋ก ์ธ์ ํฉ๋๋ค. ("1", "true")
undefined๋ ์ ์๊ฐ ๋์ง ์์์ ์๋ฏธํ๊ณ
null์ ์กด์ฌํ์ง ์์์ ์๋ฏธ ํฉ๋๋ค.
(๊ทธ๋ฌ๋ฉด์ null ์์ฒด๊ฐ ๊ฐ์ผ๋ก์จ ์กด์ฌํ์ง ์๋ ๊ฐ์ผ๋ก๋ ์ฐ์ ๋๋ค.)
NaN์ Not a Number๋ก 5 * "hello"์ ๊ฐ์ด ์ซ์ * string์ ํ ๊ฒฝ์ฐ ์ซ์๊ฐ ์๋๋ฏ๋ก NaN๊ฐ ์ถ๋ ฅ๋ฉ๋๋ค.