this1 JavaScript: this this는 상황마다 다른 것을 가리킨다. 먼저 선언해준 것이 있을 때의 this는 선언해준 것을 가리키고, 선언해준 것이 없을 때의 this는 window를 가리키게 된다. function Example(value, number) { this.value = value; this.number = number; } 이때, 프로토타입을 이용한다면 Example.prototype = { construnctor: Example, init: function () { window.addEventListener("click", function () { this. }); }, }; 이렇게 이용할 수 있지만, click이벤트 안에서 this를 쓰게된다면, 이 상황에서는 window를 가리키게 된다. 생성자함수 안에서의 t.. 2020. 6. 1. 이전 1 다음