아래 예시에서 함수 arrow()의 this는 외부 함수 user.sayHi()의 this가 됨.
이라고 하셨는데, 이해가 잘 가지않아서요..ㅠㅠ
user.sayHi()의 this firstName도 보라 아닌가요?
(1번)
let user = {
firstName: "보라",
sayHi() {
let arrow = () => alert(this.firstName);
arrow();
}
};
user.sayHi(); // 보라
음 그러니까 위의 코드에서
(2번)
let user = {
firstName: "보라",
sayHi() {
this.firstName;
let arrow = () => alert(this.firstName);
arrow();
}
};
user.sayHi(); // 보라
굵게 표시한부분이.. 1번 2번 차이가없는거아닌가요?
글로 작성하려니까 어렵네요 죄송합니다.
에로우평선에서의 this를 조금 더 엿듣고싶은데 들려주시면 안될까요..