Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2023년 7월.
Array 인스턴스의 toReversed() 메서드는 reverse()에 대응되는 복사 메서드입니다. 이 메서드는 요소들을 반대로 뒤집은 새로운 배열을 반환합니다.
없음.
역순으로 정렬된 새로운 배열을 반환합니다.
toReversed() 메서드는 호출한 배열 객체의 요소를 반대로 변경하고 새로운 배열을 반환합니다.
희소 배열에서 사용할 때, toReversed() 메서드는 빈 슬롯을 undefined 값으로 간주하고 반복합니다.
toReversed() 메서드는 범용적입니다. this 값이 length 속성과 정수로 키가 지정된 속성을 가지고 있다고 기대합니다.
다음 예제는 세 개의 요소를 가진 items 배열을 생성하고, 이를 반대로 뒤집은 새로운 배열을 생성합니다. items 배열은 변경되지 않습니다.
toReversed()의 반환 값은 절대 희소 배열이 아닙니다. 빈 슬롯은 반환된 배열에서 undefined가 됩니다.
toReversed() 메서드는 this의 length 속성을 읽습니다. 그런 다음 length - 1과 0 사이의 각 인덱스를 내림차순으로 방문하고, 원래 배열의 해당 인덱스의 값을 새 배열의 해당 인덱스에 추가합니다.
| ECMAScript® 2027 Language Specification # sec-array.prototype.toreversed |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025년 10월 10일 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.