const singleArg = arg => {
// 함수 내용
};
class Example {
constructor() {
this.value = 1;
}
arrowFunction() {
setTimeout(() => {
console.log(`Arrow Function: ${this.value}`);
}, 1000);
}
regularFunction() {
setTimeout(function() {
console.log(`Regular Function: ${this.value}`);
}, 1000);
}
const exampleObj = new Example();
exampleObj.arrowFunction(); // 출력: Arrow Function: 1
exampleObj.regularFunction(); // 출력: Regular Function: undefined
}
ArrowFunction과 Function의 차이점 중 큰 중요도는 this인거 같다.
상황에 따라서 ArrowFunction과 Function을 사용하면 좋을거같다.