this가 가리키는 것
·
Javascript
자바스크립트에서의 this는 객체를 가리키는 키워드며, 어떻게(누가) 호출하는지에 따라 결정됩니다. 자세히 말하면, this는 호출한 주체입니다. *아래 예제들은 ‘use strict’를 사용하지 않을 경우를 다룹니다. 호출 주체에 따른 this 호출주체: 전역스코프 console.log(this); // {...window} function printThis() { console.log(this); } // printThis를 호출한 것은 Window이므로 Window 객체를 출력합니다. printThis(); // {...window} 호출주체: Object function printThis() { console.log(this); } const object = { printThis1: printTh..