Home πŸ“Έ 2022-08-03
Post
Cancel

πŸ“Έ 2022-08-03

πŸ”₯ 였늘 어디에 도전해보셨고, 무엇을 λ°°μš°μ…¨λ‚˜μš”?

  • React의 state μŠ€μΌ€μ€„λ§κ³Ό useMemo
  • μžλ°”μŠ€ν¬λ¦½νŠΈμ˜ ν΄λ‘œμ €

🌊 ν•™μŠ΅ν•˜μ‹œλ©΄μ„œ κΆκΈˆν•˜μ‹  λΆ€λΆ„μ΄λ‚˜, μ–΄λ €μ› λ˜ 점은 λ­˜κΉŒμš”?

🌟 내일은 μ–΄λ–»κ²Œ 해보고 μ‹ΆμœΌμ„Έμš”?

  • useMemo와 ν΄λ‘œμ € λ‹€μ‹œ μ •λ¦¬ν•˜κΈ°

μžλ°”μŠ€ν¬λ¦½νŠΈ ν΄λ‘œμ €

πŸ”– ν•¨μˆ˜λ₯Ό λ§Œλ“€κ³  κ·Έ ν•¨μˆ˜ λ‚΄λΆ€μ˜ μ½”λ“œκ°€ νƒμƒ‰ν•˜λŠ” μŠ€μ½”ν”„λ₯Ό ν•¨μˆ˜ 생성 λ‹Ήμ‹œμ˜ λ ‰μ‹œμ»¬ μŠ€μ½”ν”„λ‘œ κ³ μ •ν•˜λ©΄ λ°”λ‘œ ν΄λ‘œμ €κ°€ λ˜λŠ” 것이닀.

πŸ”– κ°œλ…μ μœΌλ‘œ μžλ°”μŠ€ν¬λ¦½νŠΈμ˜ λͺ¨λ“  ν•¨μˆ˜λŠ” ν΄λ‘œμ €μ΄μ§€λ§Œ, λ‚΄λΆ€ ν•¨μˆ˜κ°€ ν¬ν•¨λœ ν•¨μˆ˜(μ—¬κΈ°μ„œλŠ” outer)의 μ™ΈλΆ€μ—μ„œ λ‚΄λΆ€ ν•¨μˆ˜(μ—¬κΈ°μ„œλŠ” inner)λ₯Ό ν˜ΈμΆœν•˜μ—¬ μ™ΈλΆ€ ν•¨μˆ˜μ˜ μŠ€μ½”ν”„λ₯Ό μ°Έμ‘°ν•˜λ©΄ ν΄λ‘œμ €λΌκ³  ν•œλ‹€.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const outer(param){
    const outerParam = `outer : ${param}`;

    const inner(){
        console.log(outerParam);
    }

    return inner;
}


//outerλŠ” innerν•¨μˆ˜λ₯Ό λ°˜ν™˜ν•œλ‹€.
const closure = outer("CLOSURE");

//inner ν•¨μˆ˜κ°€ μƒμ„±λœ outer ν•¨μˆ˜μ˜ 싀행이 μ’…λ£Œλ˜μ—ˆμ–΄λ„ innerλŠ” outer의 μŠ€μ½”ν”„μ— μ ‘κ·Όν•  수 μžˆλ‹€.
closure();  //outer : CLOSURE

🐝 참고

Javascript Closure? ν΄λ‘œμ €? 그리고 ν΄λ‘œμ € μ‚¬μš©ν•΄ module을 λ§Œλ“€κΈ°!

μžλ°”μŠ€ν¬λ¦½νŠΈμ˜ μŠ€μ½”ν”„μ™€ ν΄λ‘œμ €

This post is licensed under CC BY 4.0 by the author.

πŸ“Έ 2022-08-02

🍊 2022-08-08