In the following Javascript code snippet,
the callback function cb is a function that sums the value of two numbers.
Fill in the blank so that when the function is passed into the higher order function hof,
it is then invoked so that the value returned is 8.
let cb = (n1, n2) => {return n1 + n2};
let hof = (func) => {
let value = cb(3, 5); // 여기
return `this function returned ${value}`;
}
hof(cb) // 'this function returned 8'
답은 func(3, 5)인데 지금 이해가 안 가고 있다
왜지>??? 아 헐
callback function은 anonymous하다는 걸 또 잊어버렸고
그걸 또 글로 쓰는 도중에 생각이 났다
멍청인가봐...
그래도 답을 알아서 속시원해짐ㅋㅋㅋㅋㅋ
기억해...
callback function is always anonymous...
'개발 일기' 카테고리의 다른 글
[Javascript] 아니 그래서 왜 filter method 안에 return이 있어야 하는 건데? (0) | 2022.10.09 |
---|---|
[Javascript] 힘내자 진짜... (0) | 2022.10.07 |
[Javascript] 푹 쉬고 다시 시작 (0) | 2022.10.04 |
[Javascript] .reduce() method에서 살짝 위기가 찾아옴 지금 (0) | 2022.10.04 |
[Javascript] higher-order function은 뭔데? (0) | 2022.10.04 |