화살표함수
✔️단축 문법
// exp1
setTimeout(function() {
console.log("settimeout") ;
}, 1000) ;
//arrow function으로 만들기
setTimeout(() => {
console.log("settimeout") ;
}, 1000) ;
// exp2
const newArr = [1,2,3,4,5].map(function(value, index, object){
return value*2 ;
})
// arrow function
const newArr = [1,2,3,4,5].map((value) => value*2 );
)
//exp4
() => ({ a : 1 });✔️this
일반 함수의 this
콜백함수 내부의 this 설정
화살표함수의 this
✔️화살표 함수를 사용하면 안되는 경우
1. 메서드
2. prototype
3. 생성자 함수
4. addEventListener 함수의 콜백 함수
참고문서
Last updated