Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- js
- Beesbeesbees
- CSS
- redux์ํ์ ์ง
- toString#String
- slice/splice/split
- ์๋ฐ์คํฌ๋ฆฝํธ
- User Flow
- cmarket
- variable#function
- ๋ ธ๋๊ต๊ณผ์
- children vs childrenNodes
- https://developer-talk.tistory.com/299
- for~in/for~of
- react
- ์๋ฐ์คํฌ๋ฆฝํธ#JS#var#let#const#undefined#null
- https://lo-victoria.com/introduction-to-redux-toolkit-for-beginners
- UI
- ์๋ฐ์คํฌ๋ฆฝํธ#์กฐ๊ฑด๋ฌธ#๋ฌธ์์ด
- JS#3์ผ์ฐจ๋ฌ๋ฆฌ์#์ด๋ฐ์ธ๋ฐ#์๊ฐ๊ธ๋ฐฉ~
- ๋ด์ฅ๊ณ ์ฐจํจ์
- https://dasima.xyz/%EC%9E%90%EB%B0%94%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8-%EC%A0%9C%EA%B3%B1-math-pow-%EA%B3%84%EC%82%B0/
- ใทใ
- https://www.daleseo.com/js-array-slice-splice/
- ํท๊ฐ๋ฆฐ๋ค~
- dom
- @redux-toolkit
- ์๋ฐ์คํฌ๋ฆฝํธ#JS#slice#splice
- removeCookie
- UX
Archives
- Today
- Total
Daily Front_Minhhk
[JS] ๋ณ์, ํจ์ ๋ณธ๋ฌธ
๐ฅ ํ๋ฃจ์ ์์ ์ ์ ์ฐจ๋ฆฌ์! ์ ์ ๊นจ์ ์ค์ ๋ฐ์ ๋๋ฌด ํ๋ค๋คใ ใ โฉ
๐ก ์ค๋ ์ฒ์์ผ๋ก ํ์ดํ๋ก๊ทธ๋๋ฐ์ ํ๋ค! ํ์ด์ ํจ๊ป ๋ณต์ต๊ฒธ์ฌ ๋ฌธ์ ํ๊ณ , ๋ํ๋ฅผ ํ๋ฉฐ ์งํํ๋ฉฐ ๊ด์ฐฎ์ ๊ฒฝํ์ด์๋ค. ์์ผ๋ก๋ ๊ณ์ ํํ๋ฅผ ํ ํ ๋ฐ ์ด์ฌํ ์ ํด๋ด์ผ๊ฒ ๋ค?! ๋ผ๋ ๋ค์ง!
๋ณ์
- ๋ฐ์ดํฐ ๋ณด๊ดํจ ( ๋ฉ๋ชจ๋ฆฌ )
- ๋ณด๊ดํจ์ ํฌ๊ธฐ๋ ๋ชจ๋ ๋์ผ - ๊ธฐ๋ณธ 8bytes
- ๊ฐ ๋ณด๊ดํจ์ ์ด๋ฆ = ๋ณ์
- ๋ณด๊ดํจ์ ํ๋ณดํ๋๊ฑด let ํค์๋์ ๋ณ์์ ์ด๋ฆ์ ์ฌ์ฉ
let age ;
- ํ๋ณด๋๋ฉด ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํฉ๋๋ค. ์ด๋ฅผ ํ ๋น์ด๋ผ๊ณ ํ๋ค.
age = 20;
- ์ด๋ ๋ฑํธ ๊ธฐํธ๋ ๊ฐ๋ค๊ฐ ์๋๋ผ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ๋ค ๋ผ๋์ ์ ์ฃผ์ํด์ผ ํ๋ค.
- ์ ์ธ๊ณผ ํ ๋น ๋์์ ๊ฐ๋ฅ
let name = 'kim' ;
- consol.log(age*2) ๊ฐ 20๊ฐ ๋๋ค.
- 'hello' + name ์ ํ๋ฉด hello kim ์ถ๋ ฅ ( ์ด๋ name์๋ ๋ฐ์ดํ๋ฅผ ์ฐ์ง ์๋๋ค. ์ด๋ฏธ name๋ณ์์ 'kim'์ด ํ ๋น ๋ฌ๊ธฐ ๋๋ฌธ.)
typeof ๋ก ์๋ฃํ์ ์ด๋ค ํ์์ธ๊ฐ? ์ถ๋ ฅ ๊ฐ๋ฅ
์์ ์๋ฃํ
string, number, boolean, undefined
<aside> ๐ฉ๐ป๐ undefined ๋ ํ์ ์ด๊ณ ํจ์๋ ํ์ ์ด๋ค!!
</aside>
์ฐ์ฐ์๋ ํผ์ฐ์ฐ์์ ํ๊ฐ ์ ์๋ฃํ์ ๋ํ๋ด๋ ๋ฌธ์์ด์ ๋ฐํ!
// Numbers
typeof 3 === 'number';
typeof 3.14 === 'number';
typeof NaN === 'number'; //NotANumber ์์๋ number ์ถ๋ ฅ^^
typeof Number(1) === 'number';
// Strings
typeof "dd" === 'string';
typeof "asdf" === 'string';
// Booleans
typeof true === 'boolean';
typeof false === 'boolean';
console.log(typeof (1<2)) == boolean
// Undefined
typeof undefined === 'undefined';
ํจ์
function aaa(num){}
- ํค์๋(function)
- ์ด๋ฆ(aaa)
- ํ๋ผ๋ฏธํฐ(num)
ํจ์๋ ์ฝ๋์ ๋ฌถ์ ์ด๋ค!
- ๋ฒํผ์ฒ๋ผ ํ์ํ ๋ ์ฌ์ฉํ ์ ์๋ค. (๊ธฐ๋ฅ์ ๋จ์)
- ํจ์๋ ๊ตฌ์ฒด์ ์ธ ์ ๋ ฅ๊ฐ๊ณผ ์ถ๋ ฅ๊ฐ์ ๊ฐ์ง ์ ์๋ค.
- ํจ์๋ ํธ์ถํ์๋ ๋ฐ๋์ ๋์์จ๋ค(return)
ํจ์์ ๊ธฐ์ด
๋ฐ๋ณต๋๋ ์ผ์ด ํ์ํ ๊ฒฝ์ฐ ํจ์๋ฅผ ์ฌ์ฉํ๋ฉด ํธํ๋ค!(๋ํ์ ๋์ด ๊ตฌํ๊ธฐ)
ํจ์๋ ์ ๋ ฅ๊ณผ ์ถ๋ ฅ์ด ์๋ค.
return๋ฌธ์ด ์ฌ์ฉ๋์ง ์์๋ค๋ฉด undefined๊ฐ ๋ฌ๋ค!
ํจ์๋ฅผ ์ ์ธํ๋ค๋ ๊ฒ์?
3๊ฐ์ง๊ฐ ์๋ค.
- ํจ์์ ์ธ๋ฌธ์ผ๋ก ์ ์ธํ๋ ๊ฒฝ์ฐ
function a(c,d){
let f = c*d
return f
}
c์ d๋ ์ ๋ ฅ๊ฐ์ด๋ค.
return f;
f๋ ์ถ๋ ฅ๊ฐ์ด๋ค
- ํจ์ ํํ์์ผ๋ก ํํํ๋ ๊ฒฝ์ฐ
const a = function(c,d){
let f = c*d;
return f;
}
// ๋จผ์ ๋ณ์๋ฅผ ์ ์ธํ๊ณ ์ต๋ช
ํจ์๋ฅผ ํ ๋นํ๋ค!!
- ํ์ดํ ํจ์๋ก ํํํ๋ ๊ฒฝ์ฐ
const plus = (x,y) => {
let result = x+y;
return result;
}
// ํจ์ํํ์์ ๊ธฐ๋ฐ์ผ๋ก ํ๊ธฐ ๋๋ฌธ์ ๋ณ์์ ์ธํ
// ํ์ดํ๋ก ์ต๋ช
ํจ์ ํ ๋น!!
ํ์ดํํจ์ >>
const a = (c,d) => c*d // ์ ์์๋
cosnt a = (c,d) => {c*d} // ์ค๋ฅ!! undefined ๋ฆฌํด
ํจ์ ๋ณธ๋ฌธ์ return๋ฌธ๋ง ์์ผ๋ฉด return์๋ต ๊ฐ๋ฅ! (์ฃผ์! ์ค๊ดํธ๋ ์๋ตํด์ผ ์ ์์๋)
ํจ์๋ฅผ ํธ์ถํ๋ค๋ ๊ฒ์?
ํจ์๋ฅผ ํธ์ถํ๋ค.
plus(1,2); // 1+2 == 3
- ๋งค๊ฐ๋ณ์(parameter)→ ํจ์๋ฅผ ์คํํ ๋ ์ ๋ ฅ์ ๋ฐ๋ผ์ ๋ฐ๋ ์ ์๋ ๋ณ์. ํค์๋ ์์ฐ๊ณ ์ฌ์ฉ๊ฐ๋ฅ
- ์ ๋ฌ์ธ์(argument)→ ํจ์๋ฅผ ํธ์ถํ ๋ parameter์ ํ ๋น๋๋ ๊ฐ์ ๋งํจ.
Chapter1. ๋ณ์
- ๋ณ์ ์ฌ์ฉ์ ๋ฐ์ดํฐ๋ฅผ ํธ๋ฆฌํ๊ฒ ์ ์ฅํ๊ณ ๊บผ๋ด ์ฐ๋ ๊ฒ์์ ์ดํดํ๋ค.
- JavaScript์์ ๋ณ์์ ์ ์ธ๊ณผ ๊ฐ์ ํ ๋น์ ๋ํด์ ์ค๋ช ํ ์ ์๋ค.
- =๊ฐ "๊ฐ๋ค"๋ผ๋ ์๋ฏธ๊ฐ ์๋๋ผ ํ ๋น ์ฐ์ฐ์์์ ์ดํดํ ์ ์๋ค.
- ํฌ๋กฌ ๊ฐ๋ฐ์ ๋๊ตฌ์ console ํญ์ ์ด์ฉํ์ฌ ์ํ๋ ๊ฐ์ ์ถ๋ ฅํ ์ ์๋ค.
- ๋ณ์๋ฅผ ์ฌ์ฉํ์ฌ ๋ณด๋ค ํจ๊ณผ์ ์ผ๋ก ๊ตฌ๊ตฌ๋จ์ ์ถ๋ ฅํ ์ ์๋ค.
Chapter2. ํ์
- ์์ ์๋ฃํ string, number, boolean, undefined์ ์๋ฏธ๋ฅผ ์ดํดํ ์ ์๋ค.
- ํ์ ๋ง๋ค ๋ค๋ฅธ ์์ฑ๊ณผ ๋ฉ์๋๊ฐ ์๋ค๋ ๊ฒ์ ์ดํดํ ์ ์๋ค.
- typeof ๋ฅผ ํ์ฉํ์ฌ ํน์ ๊ฐ์ ํ์ ์ ํ์ธํ ์ ์๋ค.
- ๋น๊ต ์ ์๋ฐํ ๋น๊ต( === ๊ณผ !== )์ ํ์์ฑ์ ์ดํดํ ์ ์๋ค.
Chapter3. ํจ์
- ํจ์๊ฐ "์์ ๊ธฐ๋ฅ์ ๋จ์"๋ผ๋ ๊ฒ์ ์ดํดํ ์ ์๋ค.
- ํจ์ ์ ์ธ์ ์ํด ํ์ํ keyword, name, parameter, body์ ๋ํด ์ดํดํ ์ ์๋ค.
- ํจ์์ ํธ์ถ๊ณผ ๋ฆฌํด์ ๋ํด์ ์ดํดํ๊ณ , ์ค์ ์ฝ๋๋ก ์์ฑํ์ฌ ํ์ฉํ ์ ์๋ค.
- ํจ์ ๊ทธ ์์ฒด(func)์, ํจ์์ ํธ์ถ(func())๋ฅผ ๊ตฌ๋ถํ์ฌ ์ฌ์ฉํ ์ ์๋ค.
- ๋งค๊ฐ๋ณ์(parameter)์ ์ ๋ฌ์ธ์(argument)๋ฅผ ๊ตฌ๋ถํ์ฌ ์ฌ์ฉํ ์ ์๋ค.
- ๊ฐ์ ๊ธฐ๋ฅ์ ํ๋ ํจ์๋ฅผ ์ ์ธ์, ํํ์, ํ์ดํ ํจ์๋ก ๋ฐ๊พธ์ด ํํํ ์ ์๋ค.
'Code๊ฐ๋ฐ์ผ์ง' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JS] Number ํ์ ์ String ํ์ ์ผ๋ก ๋ณํ// toString(), String(), num+'',Template String ${(num)} (0) | 2022.10.25 |
---|---|
[JS] ๋ฐฐ์ด์ slice()์ splice() ํจ์ (0) | 2022.10.24 |
[JS] ์กฐ๊ฑด๋ฌธ, ๋ฌธ์์ด (0) | 2022.10.24 |
[JS] undefined์ null์ ์ฐจ์ด์ / var let const ์ฐจ์ด์ (0) | 2022.10.24 |
[JS] typeof ๋ก ํ์ ํ์ธ! (0) | 2022.10.21 |