JavaScript
2023. 2. 19.
'this' ํค์๋์ ๋ค์ํ ์ฌ์ฉ
'this' ํค์๋์ ๋ค์ํ ์ฌ์ฉ ๋ณธ์ธ์ ๋ด๊ณ ์๋ ์ค๋ธ์ ํธ๋ฅผ ํํ ํจ์๋ฅผ ํฌํจํ๊ณ ์๋ ์ค๋ธ์ ํธ (์ค๋ธ์ ํธ ๋ด ํจ์(๋ฉ์๋)์์ ์ฌ์ฉ, arrow function ์ผ ์ ํจ์๋ฐ์ ์๋ this๋ฅผ ๊ทธ๋๋ก ์ฌ์ฉ) window (์ ์ญ์ ์ ์ธ, ํจ์ ์์ ์ ์ธ(strict ๋ชจ๋์์ undefined)) -> ํจ์๋ ๋ณ์๋ฅผ ์ ์ญ ๊ณต๊ฐ์ ๋ง๋ค๋ฉด window(global object)์์ ๋ณด๊ดํ๊ธฐ ๋๋ฌธ constructor์์์ this ํค์๋ ์๋ก ์์ฑ๋๋ object(instance)๋ฅผ ์๋ฏธ addEventListener์ function์์ ์ฌ์ฉ ์ e.currentTarget ( e.currentTarget๋? ์ด๋ฒคํธ๊ฐ ๋์ํ๊ณ ์๋ HTML ์์ ) ๋ณธ์ธ์ ๋ด๊ณ ์๋ ์ค๋ธ์ ํธ๋ฅผ ํํ let data = {..