728x90 반응형 function context2 'this'를 갈고 닦자! 이번 글은 'JavaScriptの理解を深めた人がさらにもう1歩先に進むための本(JavaScript를 깊게 이해한 사람이 한 걸음 더 나아가기 위한 책)의 Chapter 3. thisを極めよう!(this를 갈고 닦자!)'를 바탕으로 작성하였습니다. 함수에서 호출했을 때의 'this' 함수에서 호출했을 때 this는 global object를 가리킨다. 대부분의 경우 JavaScript는 브라우저에서 동작하기 때문에 global object는 'window object'를 가리키는 것이다. function checkThis() { console.log(this); // Window ※ 브라우저에서 실행했을 경우 this.val = 'test'; // global scope member로 추가됨 } checkTh.. 2022. 4. 7. 함수 장인이 되는 길_함수 호출에 대한 이해 from Secrets of the JavaScript Ninja 이번 글은 'Secrets of the JavaScript Ninja'의 'Chapter 4. Funtions for the journeyman: understanding function invocation'를 바탕으로 작성하였습니다. 핵심 Concepts function의 내재된 parameter 2가지: argumnets & this 함수 호출 방법 function contexts에 생긴 문제 해결 사전 지식 체크! this parameter가 function context로 알려진 이유? function과 method의 차이? constructor function이 명확하게(explicitly) object를 반환하면 생기는 일? 들어가며 이번 글에서는 내재적인(implicit) function p.. 2022. 4. 6. 이전 1 다음 728x90 반응형