aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/javascript/reference/global_objects/array/reverse/index.html
blob: 95b4c1a3486b79ae18b2ab13e360c144e1d93c6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
title: Array.prototype.reverse()
slug: Web/JavaScript/Reference/Global_Objects/Array/reverse
tags:
  - Array
  - JavaScript
  - Method
  - Prototype
translation_of: Web/JavaScript/Reference/Global_Objects/Array/reverse
---
<div>{{JSRef}}</div>

<p><code><strong>reverse()</strong></code> 메서드는 배열의 순서를 반전합니다. 첫 번째 요소는 마지막 요소가 되며 마지막 요소는 첫 번째 요소가 됩니다.</p>

<p>{{EmbedInteractiveExample("pages/js/array-reverse.html")}}</p>

<h2 id="구문">구문</h2>

<pre class="syntaxbox"><code><var>a</var>.reverse()</code></pre>

<h3 id="반환_값">반환 값</h3>

<p>순서가 반전된 배열.</p>

<h2 id="설명">설명</h2>

<p><code>reverse</code> 메서드는 호출한 배열을 반전하고 원본 배열을 변형하며 그 참조를 반환합니다.</p>

<h2 id="예시">예시</h2>

<h3 id="배열의_요소를_반전하기">배열의 요소를 반전하기</h3>

<p>다음 예시는 3개의 요소가 든 myArray 배열을 만든 후, 반전시킵니다.</p>

<pre><code>const a = [1, 2, 3];
console.log(a); // [1, 2, 3]

a.reverse();
console.log(a); // [3, 2, 1]</code></pre>

<h2 id="명세">명세</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('ES1')}}</td>
   <td>{{Spec2('ES1')}}</td>
   <td>Initial definition. Implemented in JavaScript 1.1.</td>
  </tr>
  <tr>
   <td>{{SpecName('ES5.1', '#sec-15.4.4.8', 'Array.prototype.reverse')}}</td>
   <td>{{Spec2('ES5.1')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-array.prototype.reverse', 'Array.prototype.reverse')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-array.prototype.reverse', 'Array.prototype.reverse')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="브라우저_호환성">브라우저 호환성</h2>

<div>{{Compat("javascript.builtins.Array.reverse")}}</div>

<div id="compat-desktop"> </div>

<div id="compat-mobile"> </div>

<h2 id="같이_보기">같이 보기</h2>

<ul>
 <li>{{jsxref("Array.prototype.join()")}}</li>
 <li>{{jsxref("Array.prototype.sort()")}}</li>
 <li>{{jsxref("TypedArray.prototype.reverse()")}}</li>
</ul>