# 13.6.2 함수에 함수 전달

함수에 함수를 전달하는 함수 : 콜백 (callback)&#x20;

<예제>

```javascript
function sum (arr, f) {
    // 함수가 전달되지 않았으면 매개변수를 그대로 반환하는 null 함수를 사용
    if (typeof f != 'function') f = x => f
    
    return arr.reduce((a, x) => a += f(x), 0);
}

sum([1, 2, 3]); // 6
sum([1, 2, 3], x => x*x); // 14
sum([1, 2, 3], x => Math.pow(x, 3)); // 36
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://april.gitbook.io/learning-js/chapter-13./13.6/13.6.2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
