this (1) 썸네일형 리스트형 [javascript] this 란 1. this javascript의 this는 다른 언어의 this와 동작하는 방식이 조금 다릅니다. javascript에서 대부분의 경우 this는 함수를 호출하는 방법에 따라 결정됩니다. 즉, 함수를 호출 할 때 마다 this가 가리키는 값이 다를 수 있습니다. 2. 전역에서 this를 호출 했을 경우 console.log(this); // window 전역에서의 this는 기본적으로 window 객체를 가리킵니다. 3. 함수 안에서 this를 호출 했을 경우 function doSomething(){ return this; } console.log(doSomething()); // window console.log(window.doSomething()); // window this를 결정하는 건 대.. 이전 1 다음