this

    [JavaScript] This 포인터 이해하기

    [JavaScript] This 포인터 이해하기

    This 포인터 앞서 This 포인터가 포함된 실행 Context와 Scope에 대해 알아보았다. This로 특정 위치를 참조 할 수 있다. 클래스 내부를 참조할 때 this를 함께 사용함을 본적이 있을 것이다. 또, 일반 함수형과 화살표 함수의 큰 차이점이 바로 이 this 포인터이다. function myFunc(){ console.log("myFunc called"); } myFunc(); //함수 직접 호출 const o ={ name : 'Daniel', printName : function(){ console.log(this.name)} } o.printName(); //객체릐 메서드를 호출 function Person(name){ this.name = name this.printName = ..