화살표 함수는 자체적으로 this를 가지지 않는다.
사진과 같이 화살표 함수에서 사용되는 this는 선언 된 객체의 프로퍼티 titles를 가리키고 있음
const arrowFunc = () => {};
const normalFunc = function() {
};
// new arrowFunc(); // 에러발생, arrowFunc is not a constructor
new normalFunc();
let test = function() {
console.log(arguments);
const arrowFunc = () => console.log(arguments);
// const arrowFunc = function() {
// console.log(arguments);
// };
arrowFunc(3, 4);
};
test(1, 2);
// console 결과
//[Arguments] { '0': 1, '1': 2 }
//[Arguments] { '0': 1, '1': 2 }
1번 예제와 비슷한 맥락으로 자신의 함수가 아닌 외부로부터 호출 받은 값을 우선 시 한다.
arguments 자체가 가변의 성질을 갖고 있어 받아온 값들을 생성해주는 타입인데 해당 예시 에서는 화살표 함수에 존재하는 arguments는 함수 내부의 arguments를 바라보고 있는 것이 아닌 외부로 부터 받은 arguments 즉, (1, 2)를 보고 있다.
함수 내부의 arguments(3, 4)를 보고 있지 않음.