# 8.2.1 배열의 처음이나 끝에서 요소 하나를 추가하거나 제거하기

### 배열의 처음

첫 번째 요소 (인덱스가 0)

### 배열의 끝

인덱스가 가장 큰 요소 (배열이 arr이라면 arr.length-1인 요소를 말함)

### push

배열의 끝에 요소를 추가

### pop

배열의 끝에 요소를 제거

### shift

배열의 처음에 요소를 제거

### unshift

배열의 처음에 요소를 추가

```javascript
const arr = ["b", "c", "d"];
arr.push("e"); // ["b", "c", "d", "e"]
arr.pop(); // ["b", "c", "d"]
arr.unshift("a"); // ["a", "b", "c", "d"];
arr.shift(); // ["b", "c", "d"]
```


---

# 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-8./8.2/8.2.1.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.
