개발/react 생태계
Uncaught TypeError: func is not a function at b (<anonymous>:11:6) at <anonymous>:1:1
도깨비!
2020. 5. 21. 17:49
반응형
const b =(a, func) => {
func(a);
}
b(1, console.log(123));
위 경우에서 b(a())을 실행할 경우 아래 에러가 발생합니다.
```
Uncaught TypeError: func is not a function at b (<anonymous>:11:6) at <anonymous>:1:1
```
이는 console.log()를 인자로 전달해야하는데, 실행을 했기때문에 발생하는 오류입니다. 수정 코드는 아래와 같습니다.
const b =(a, func) => {
func(a);
}
b(1, () => {
console.log(123)
});
함수를 파라미터로 넘겨줄때, 실행하면 안된다는 점 잊지마세요~