javascript basic #1 ๋ณ€์ˆ˜

๐Ÿถยท2021๋…„ 5์›” 14์ผ
0

๊ฐœ๋… ์ •๋ฆฌ

๋ชฉ๋ก ๋ณด๊ธฐ
1/41

๐Ÿ“์˜ค๋Š˜ ๋ฐฐ์šด ๊ฒƒ

๐Ÿ’ฌ What is variable?

๋ณ€์ˆ˜๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ๋‹ค๋ฃจ๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค.

์•„๋ž˜์™€ ๊ฐ™์ด ๊ตฌ๊ตฌ๋‹จ์„ ์ถœ๋ ฅํ•  ๋•Œ

console.log(3*1)
console.log(3*2)
console.log(3*3)
console.log(3*4)
console.log(3*5)
console.log(3*6)
console.log(3*7)
console.log(3*8)
console.log(3*9)

๋™์ผํ•˜๊ฒŒ ๋ฐ˜๋ณต๋˜๋Š” ๋ฐ์ดํ„ฐ(=3)์„ ๋ณ€์ˆ˜(=num)๋กœ ๋Œ€์ฒดํ•˜๊ณ 
๋ณ€์ˆ˜์— ํ•ด๋‹น ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋‹ค.

let num = 5
console.log(num*1)
console.log(num*2)
console.log(num*3)
console.log(num*4)
console.log(num*5)
console.log(num*6)
console.log(num*7)
console.log(num*8)
console.log(num*9)

๐Ÿ’ฌ What does it mean?

์ปดํ“จํ„ฐ์—๋Š” ๋ฐ์ดํ„ฐ ๋ณด๊ด€ํ•จ์ด ์กด์žฌํ•˜๋Š”๋ฐ(์ด ๋ณด๊ด€ํ•จ์€ ๋ฉ”๋ชจ๋ฆฌ)
๋ณด๊ด€ํ•จ์˜ ํฌ๊ธฐ๋Š” ๋™์ผํ•˜๋‹ค
๊ฐ ๋ณด๊ด€ํ•จ์˜ ์ด๋ฆ„ = ๋ณ€์ˆ˜(๋ฐ์ดํ„ฐ์˜ ์ด๋ฆ„ํ‘œ์ž„)
์ด๋ฆ„(=๋ณ€์ˆ˜)์„ ํ†ตํ•ด ๋ณด๊ด€๋œ ๋ฐ์ดํ„ฐ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค(์žฌํ™œ์šฉ)

๐Ÿ’ฌ How to use?

  1. ๋ฐ์ดํ„ฐ ๋ณด๊ด€ํ•จ์— ์ž๋ฆฌ๋ฅผ ํ™•๋ณด --> ์„ ์–ธ
  2. ๋ณด๊ด€ํ•จ์— ๋ฐ์ดํ„ฐ ์ €์žฅ --> ํ• ๋‹น

๐Ÿ’ฌ javascirpt ํ‘œํ˜„์‹์œผ๋กœ ๋‚˜ํƒ€๋‚ด๋ฉด?

let myname; //๋ณ€์ˆ˜ ์„ ์–ธ
myname = 'steve'; //myname์ด๋ผ๋Š” ๋ณ€์ˆ˜์— steve๋ผ๋Š” ๊ฐ’์„ ํ• ๋‹น

let myname = 'steve'; //์„ ์–ธ๊ณผ ํ• ๋‹น์„ ํ•จ๊ป˜ ํ•  ์ˆ˜ ์žˆ์Œ

์•„๋ž˜์™€ ๊ฐ™์ด ๋ณ€์ˆ˜๋Š” ๋™์ผํ•œ ๋ณ€์ˆ˜๋ฅผ ์ด์šฉํ•ด ๋Œ€์ž…ํ•  ์ˆ˜ ์žˆ๋‹ค.

let sum = 1;
sum = sum + 2; //ํ•œ๋ฒˆ ์„ ์–ธํ–ˆ๋˜ ๋ณ€์ˆ˜๋ฅผ ๋‹ค์‹œ ์‚ฌ์šฉํ•  ๋•Œ๋Š” let์„ ์“ฐ์ง€ ์•Š๋Š”๋‹ค
sum = sum + 3;
sum = sum + 4;

๐Ÿ’ฌ ๋ณ€์ˆ˜์—๋Š” ๋‹ค์–‘ํ•œ ํƒ€์ž…์ด ์žˆ๋‹ค

์ˆซ์ž
๋ฌธ์ž์—ด
Boolean(true or false)

profile
์šฐ๋‹นํƒ•ํƒ• ๊ฐœ๋ฐœ์ผ๊ธฐ๐Ÿ“๐Ÿค–

0๊ฐœ์˜ ๋Œ“๊ธ€