--- 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 ---
reverse() 메서드는 배열의 순서를 반전합니다. 첫 번째 요소는 마지막 요소가 되며 마지막 요소는 첫 번째 요소가 됩니다.
{{EmbedInteractiveExample("pages/js/array-reverse.html")}}
a.reverse()
순서가 반전된 배열.
reverse 메서드는 호출한 배열을 반전하고 원본 배열을 변형하며 그 참조를 반환합니다.
다음 예시는 3개의 요소가 든 myArray 배열을 만든 후, 반전시킵니다.
const a = [1, 2, 3];
console.log(a); // [1, 2, 3]
a.reverse();
console.log(a); // [3, 2, 1]
| Specification | Status | Comment |
|---|---|---|
| {{SpecName('ES1')}} | {{Spec2('ES1')}} | Initial definition. Implemented in JavaScript 1.1. |
| {{SpecName('ES5.1', '#sec-15.4.4.8', 'Array.prototype.reverse')}} | {{Spec2('ES5.1')}} | |
| {{SpecName('ES6', '#sec-array.prototype.reverse', 'Array.prototype.reverse')}} | {{Spec2('ES6')}} | |
| {{SpecName('ESDraft', '#sec-array.prototype.reverse', 'Array.prototype.reverse')}} | {{Spec2('ESDraft')}} |