Dream๐Ÿฐng
article thumbnail
[JS] ํด๋ž˜์Šค์™€ ์ธ์Šคํ„ด์Šค
๐Ÿ“ Study/JavaScript 2022. 9. 21. 17:30

ํด๋ž˜์Šค์™€ ์ธ์Šคํ„ด์Šค โœ๏ธ ํด๋ž˜์Šค ํด๋ž˜์Šค๋ž€? ํด๋ž˜์Šค๋Š” ์†์„ฑ๊ณผ ๋ฉ”์†Œ๋“œ๋ฅผ ์ •์˜ํ•˜๋Š” ๊ณต๊ฐ„์ด๋‹ค. ์†์„ฑ์€ ํด๋ž˜์Šค์— ํฌํ•จ๋˜๋Š” ๋ณ€์ˆ˜๋ฅผ ์˜๋ฏธํ•˜๊ณ , ๋ฉ”์†Œ๋“œ๋Š” ํด๋ž˜์Šค์— ํฌํ•จ๋˜๋Š” ํ•จ์ˆ˜๋ฅผ ์˜๋ฏธํ•œ๋‹ค. ํด๋ž˜์Šค๋ฅผ ์ •์˜ํ•˜๋Š” ๋ฐ์—๋Š” 2๊ฐ€์ง€ ๋ฐฉ๋ฒ•์ด ์žˆ๋‹ค. ํ•จ์ˆ˜๋กœ ์ •์˜ (ES5 ๋ฌธ๋ฒ•) function Introduce(name, age, favorite) { // ์ธ์Šคํ„ด์Šค ๋งŒ๋“ค์–ด์งˆ ๋•Œ ์‹คํ–‰๋˜๋Š” ์ฝ”๋“œ } class ํ‚ค์›Œ๋“œ๋กœ ์ •์˜ (ES6 ๋ฌธ๋ฒ•) class Introduce { constructor(name, age, favorite) { // ์ธ์Šคํ„ด์Šค๊ฐ€ ๋งŒ๋“ค์–ด์งˆ ๋•Œ ์‹คํ–‰๋˜๋Š” ์ฝ”๋“œ } } ์—ฌ๊ธฐ์„œ constructor๋Š” ํด๋ž˜์Šค๊ฐ€ ์ธ์Šคํ„ด์Šค ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•  ๋•Œ ๊ฐ์ฒด๋ฅผ ์ดˆ๊ธฐํ™”ํ•˜๋Š” ๋ฉ”์†Œ๋“œ์ด๋‹ค. constructor ๋ฉ”์†Œ๋“œ๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์‚ฌ์šฉํ•œ๋‹ค๋ฉด, cla..

article thumbnail
[S1U10] JavaScript ํ•ต์‹ฌ ๊ฐœ๋…๊ณผ ์ฃผ์š” ๋ฌธ๋ฒ•

์›์‹œ ์ž๋ฃŒํ˜•๊ณผ ์ฐธ์กฐ ์ž๋ฃŒํ˜• โœ๏ธ ์›์‹œ ์ž๋ฃŒํ˜• ์›์‹œ ์ž๋ฃŒํ˜•์ด๋ž€? ๊ฐ์ฒด๊ฐ€ ์•„๋‹ˆ๋ฉด์„œ method๋ฅผ ๊ฐ€์ง€์ง€ ์•Š๋Š” ์ž๋ฃŒํ˜•์œผ๋กœ ๋ณ€์ˆ˜์— ํ•˜๋‚˜์˜ ๋ฐ์ดํ„ฐ๋งŒ ์ €์žฅํ•  ์ˆ˜ ์žˆ๊ณ  ํ•ด๋‹น ๋ฐ์ดํ„ฐ๋Š” ๊ฐ’ ์ž์ฒด์ด๋‹ค. ์›์‹œ ์ž๋ฃŒํ˜• ์ข…๋ฅ˜ 6๊ฐ€์ง€ string, number, bigint, boolean, undefined, symbol, (null) "hello world!" "hello september!" // "hello world"์™€ "hello september!"์€ ๋ชจ๋‘ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์—†๋Š” ๊ณ ์ •๋œ ๊ฐ’์ด๋‹ค. let word = "hello world!" word = "hello september!" // word๋ผ๋Š” ๋ณ€์ˆ˜์— ์žฌํ• ๋‹น์„ ํ•˜์—ฌ ๋ณ€์ˆ˜์— ๋‹ด๊ธด ๋‚ด์šฉ์„ ๋ณ€๊ฒฝํ•˜๋Š” ๊ฒƒ์€ ๊ฐ€๋Šฅํ•˜๋‹ค. โœ๏ธ ์ฐธ์กฐ ์ž๋ฃŒํ˜• ์ฐธ์กฐ ์ž๋ฃŒํ˜•์ด๋ž€? ์›์‹œ ์ž๋ฃŒํ˜•์ด ์•„๋‹Œ..

profile on loading

Loading...