# Array 객체

| 메서드       | 설명                   |
| --------- | -------------------- |
| join()    | 배열 사이에 지정된 문자열을 추가하기 |
| reverse() | 배열을 역순으로 정렬하기        |
| sort()    | 배열 정렬하기              |
| slice()   | 배열을 일부 선택하기          |
| concat()  | 배열을 합치기              |
| shift()   | 첫 번째 배열 가져오기 또는 제거하기 |
| unshift() | 첫 번째 배열 추가하기         |
| pop()     | 마지막 배열 제거하기          |

```javascript
//Array 객체
const arr10 = [100, 200, 300, 400, 500];
const arr20 = [600, 700, 800, 900, 1000];

document.write(arr10, "<br>");
document.write(arr10.join('*'), "<br>");
document.write(arr10.reverse(), "<br>");
document.write(arr10.sort(), "<br>");
document.write(arr10.sort(function(a, b){return b - a}), "<br>");
document.write(arr10.sort(function(a, b){return a - b}), "<br>");
document.write(arr10.slice(1, 3), "<br>");
document.write(arr10.slice(2, 3), "<br>");
document.write(arr10.concat(arr20), "<br>");
document.write(arr10.shift(), "<br>");  //첫번째 값 가져오기 
document.write(arr10, "<br>");  //shift로 인해 100은 잘리고 200부터
document.write(arr10.unshift(100), "<br>");
document.write(arr10, "<br>");
document.write(arr10.pop(), "<br>");
document.write(arr10, "<br>");

//100,200,300,400,500
//100*200*300*400*500
//500,400,300,200,100
//100,200,300,400,500
//500,400,300,200,100
//100,200,300,400,500
//200,300
//300
//100,200,300,400,500,600,700,800,900,1000
//100
//200,300,400,500
//5
//100,200,300,400,500
//500
//100,200,300,400
```

### 102페이지 예제

```javascript
<script>
    let arr_1 = ["사당", "교대", "방배", "강남"];
    let arr_2 = ["신사", "압구정", "옥수"];
    
    let result = arr_1.join("-");
    console.log(result);
    
    let result = arr_1.concat(arr_2);
    console.log(result);
    
    let result = arr_1.slice(1,3);
    console.log(result);
    
    arr_1.sort();
    console.log(arr_1);
    
    arr_2.reverse();
    console.log(arr_2);
</script>
```

### 103페이지 예제

```javascript
<script>
    let greenArr = ["교대", "방배", "강남"];
    let yellowArr = ["미금", "정자", "수서"];
    
    greenArr.splice(2, 1, "서초", "역삼");
    console.log(greenArr);
    
    let data1 = yellowArr.pop();
    let data2 = yellowArr.shift();
    
    yellowArr.push(data2);
    console.log(yellowArr);
    
    yellowArr.unshift(data1);
    console.log(yellowArr);
</script>
```


---

# 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://hgy5710.gitbook.io/javascript-jquery/undefined-7/array.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.
