# 6.2 호출과 참조

* 자바스크립트에서는 함수도 객체 --> 다른 객체와 마찬가지로 **넘기거나 할당이 가능**함
* 함수 식별자 뒤에 괄호를 써서 함수 호출 (쓰지 않으면 단순 참조)
* 함수를 변수, 객체 프로퍼티, 배열 요소로 할당 가능

### 1) 함수를 변수에 할당하는 경우

```javascript
  var f = getGreeting;
  console.log(f()); // Hello, World!
  console.log(f); // getGreeting() { return "Hello, World!"; }
```

### 2) 함수를 객체 프로퍼티에 할당하는 경우

```javascript
  const o = {};
  o.f = getGreeting;
  console.log(o.f()); // Hello, World!
  console.log(o.f); // getGreeting() { return "Hello, World!"; }
```

### 3) 함수를 배열 요소에 할당하는 경우

```javascript
  const arr = [1, 2, 3];
  arr[1] = getGreeting; // arr[ 1, function getGreeting(), 2 ]
  console.log(arr[1]()); // Hello, World!
  console.log(arr[1]); // getGreeting() { return "Hello, World!"; }
```


---

# 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-6./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.
