Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

이 페이지는 영어로부터 커뮤니티에 의하여 번역되었습니다. MDN Web Docs에서 한국 커뮤니티에 가입하여 자세히 알아보세요.

Array.prototype.reverse()

BaselineWidely available

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

시도해 보기

const array1 = ["one", "two", "three"];console.log("array1:", array1);// Expected output: "array1:" Array ["one", "two", "three"]const reversed = array1.reverse();console.log("reversed:", reversed);// Expected output: "reversed:" Array ["three", "two", "one"]// Careful: reverse is destructive -- it changes the original array.console.log("array1:", array1);// Expected output: "array1:" Array ["three", "two", "one"]

구문

js
a.reverse();

반환 값

순서가 반전된 배열.

설명

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

예시

배열의 요소를 반전하기

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

js
const a = [1, 2, 3];console.log(a); // [1, 2, 3]a.reverse();console.log(a); // [3, 2, 1]

명세

Specification
ECMAScript® 2026 Language Specification
# sec-array.prototype.reverse

브라우저 호환성

같이 보기

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp