# [JavaScript]

hyena_leeยท2022๋ 8์ 23์ผ
0

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

## ๐ (์ฌ) ๊ธฐ์ด๋ค์ง๊ธฐ

string() -> ๋ฌธ์ํ์ ๋ณํ
Number() -> ์ซ์ํ์ผ๋ก ๋ณํ (Number("๋ฌธ์") // NaN
Boolean() -> ๋ถ๋ฆฐํ์ผ๋ก ๋ณํ (0, ", null, undefined, NaN -> false

#### (์ฃผ์์ฌํญ)

Number(null) // 0
Number(undefined) //NaN

Number(0) // false์ซ์์ผ ๊ฒฝ์ฐ
Number('0') // true
๋ฌธ์์ด์ผ ๊ฒฝ์ฐ
Number('') // false ๋น๋ฌธ์์ด ๊ฒฝ์ฐ
Number(' ') // true
๊ณต๋ฐฑ์ด ์์ผ๋ฉด

#### ๐ ์ฐ์ฐ์ (Operators)

• ๋ํ๊ธฐ
• ๋นผ๊ธฐ
• ๊ณฑํ๊ธฐ
/ ๋๋๊ธฐ
% ๋๋จธ์ง

Q. ๋๋จธ์ง (%)๋ฅผ ์ด๋์ ์ธ๊น?
ํ์ : X % 2 = 1
์ง์ : ใ % 2 = 0

Q. ์ด๋ค ๊ฐ์ด ๋ค์ด์๋ 5๋ฅผ ๋๊ธฐ๋ฉด ์๋ผ.
-> X % 5 = 0~4 ์ฌ์ด์ ๊ฐ๋ง ๋ฐํ

#### ๐ ๊ฑฐ๋ญ์ ๊ณฑ

const num = 2**3;
console.log(num); //8

const age = 19

if(age > 19) {
console.log('ํ์ํฉ๋๋ค');
} else if(age === 19) {
console.log('์๋ฅ ์์น์ธ์');
} else {
console.log('์๋ํ ๊ฐ์ธ์.');
}

#### ๐ ๋ผ๋ฆฌ ์ฐ์ฐ์

|| (or)
&& (AND)
! (NOT)

์) ์ด๋ฆ์ด TOM ์ด๊ฑฐ๋, ์ฑ์ธ์ด๋ฉด ํต๊ณผ

const name = "Mike"
const age = 30

if(name === TOM || age > 19) {
console.log('ํต๊ณผ');
}
if(name === 'Mike && age > 19) {
console.log('ํต๊ณผ');
} else {
console.log('๋์๊ฐ');

}

#### ๐ for๋ฌธ 1๋ถํฐ 10๊น์ง ๋ก๊ทธ

i = 0 ์ด๊ณ
i ๊ฐ 10๋ณด๋ค ์์ผ๋ฏ๋ก
์ฝ๋ ์คํ
i๊ฐ 1 ์ฆ๊ฐ
(๋ฐ๋ณต..9)

### ๐ break, , continue

break : ๋ฉ์ถ๊ณ , ๋น ์ ธ๋์ด
continue : ๋ฉ์ถ๊ณ  ๋ค์ ๋ฐ๋ณต์ผ๋ก ์งํ

### ๐ ์ ์ญ ๋ณ์์ ์ง์ญ ๋ณ์

• ํ๋ฒ์ ํ ์์์ ์ง์ค
• ์ฝ๊ธฐ ์ฝ๊ณ  ์ด๋ค ๋์์ธ์ง ์ ์ ์๊ฒ ๋ค์ด๋ฐ
showError - ์๋ฌ๋ฅผ ๋ณด์ฌ์ค
getName = ์ด๋ฆ์ ์ป์ด์ด
createUserData - ์ ์ ๋ฐ์ดํฐ ์์ฑ

### ๐ ํ์ดํ ํจ์

ํจ์ ํํ์๋ณด๋ค ๋จ์ํ๊ณ  ๊ฐ๊ฒฐํ ๋ฌธ๋ฒ์ผ๋ก ํจ์๋ฅผ ๋ง๋ค ์ ์๋ ๋ฐฉ๋ฒ์ด ์๋ค.
๋ฐ๋ก ํ์ดํ ํจ์(arrow function)๋ฅผ ์ฌ์ฉํ๋ ๊ฒ.

### ๐object

ํ์ดํ ํจ์๋ ์ผ๋ฐ ํจ์์๋ ๋ฌ๋ฆฌ ์์ ๋ง์ this ๋ฅผ ๊ฐ์ง์ง ์์
ํ์ดํ ํจ์ ๋ด๋ถ์์ this๋ฅผ ์ฌ์ฉํ๋ฉด, ๊ทธ this๋ ์ธ๋ถ์์ ๊ฐ์ ๊ฐ์ ธ์ด

๐ ๋ฐฐ์ด(Array)
: ์์๊ฐ ์๋ ๋ฆฌ์คํธ

#### ํน์ง

• ๋ฐฐ์ด์ ๋ฌธ์ ๋ฟ๋ง ์๋๋ผ, ์ซ์, ๊ฐ์ฒด, ํจ์ ๋ฑ๋ ํฌํจํ  ์ ์์.

### ๐ ๋ณ์์ ์์ฑ๊ณผ์ 

1. ์ ์ธ ๋จ๊ณ
2. ์ด๊ธฐํ ๋จ๊ณ
3. ํ ๋น ๋จ๊ณ

let 1.์ ์ธ, 2.์ด๊ธฐํ
const 1.์ ์ธ, 2.์ด๊ธฐํ, 3.ํ ๋น

### ๐ ์ค์ฝํ

var : ํจ์ ์ค์ฝํ(function-scoped)
let, const : ๋ธ๋ก ์ค์ฝํ (block-scoped)
: ํจ์, if๋ฌธ, for ๋ฌธ, while ๋ฌธ, try/catch ๋ฌธ ๋ฑ

### ๐ ์์ฑ์ ํจ์

-
์ค์๋ฅผ ๋๋ ค์ ๋ง๊ณ  ๊ณ์ ๋์  ํ๋ ๊ฐ๋ฐ์์ ์ฌ์ !