this1 [JS] this 이번 글에서는 this의 사용법에 대해서 알아볼 것이다. 일반 함수(normal)는 호출 위치에 따라 this 정의 화살표 함수(Arrow)는 자신이 선언된 함수 범위에서 this 정의! const flyda = { name : 'flyda', normal : function () { console.log(this.name) //호출 위치에서 this 정의 }, arrow : () => { console.log(this.name) // 자신이 선언된 함수 범위에서 this 정의, 지금 안에서 무엇을 지칭하는지 정확하게 알 수 없음. } } flyda.normal() // flyda flyda.arrow()//undefined const amy = { name : 'Amy', normal : flyda.n.. 2022. 4. 15. 이전 1 다음