call, bind, apply의 this binding
·
javascript
this 아무것도 없는 상태에서 this는 글로벌객체인 window를 가르킨다. 자바스크립트 this가 결정되는 시점은 선언시점이 아닌 누가 실행하는지에 따라서 결정된다. consoleA를 실행할때 testObj가 실행하고 있으므로 this는 testObj를 가르킨다. const testObj = { a: '1234', consoleA: function() { console.log(this.a); } } testObj.consoleA(); //1234 변수에 메소드를 할당해서 실행하는경우 실행할 때 this는 testObj가 아닌 window를 가르킨다. const testObj = { a: '1234', consoleA: function() { console.log(this.a); } } const t..