TypedArray.prototype.toReversed()

Baseline 2023

Newly available

Since July 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

TypedArray 인스턴스의 toReversed() 메서드는 reverse() 메서드의 복사 대응 메서드입니다. 이 메서드는 요소가 역순으로 배열된 새로운 형식화 배열을 반환합니다. 이 메서드는 Array.prototype.toReversed()와 같은 알고리즘을 가집니다.

구문

js
toReversed()

매개변수

없음.

반환 값

역순으로 정렬된 요소가 포함된 새로운 형식화 배열.

설명

자세한 정보는 Array.prototype.toReversed()을 참고하시기 바랍니다. 이 메서드는 범용 메서드가 아니며, 형식화 배열 인스턴스에서만 호출할 수 있습니다.

예제

toReversed() 사용하기

js
const uint8 = new Uint8Array([1, 2, 3]);
const reversedUint8 = uint8.toReversed();
console.log(reversedUint8); // Uint8Array [3, 2, 1]
console.log(uint8); // Uint8Array [1, 2, 3]

명세서

Specification
ECMAScript Language Specification
# sec-%typedarray%.prototype.toreversed

브라우저 호환성

BCD tables only load in the browser

같이 보기