const obj={
checkThis(){
function inner(){
console.log(this);
}
inner();
}
}
// Window {window: Window, self: Window, document: document, name: '', location: Location, …}
const objTwo={
checkThis(){
(()=>{console.log(this);})();
}
}
obj.checkThis();
objTwo.checkThis();
// {checkThis: ƒ}
화살표 함수의 this는 상위스코프의 this를 참조한다.
일반 함수의 this는 전역객체를 참조한다.