Array.prototype.reverse()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since â¨2015ë 7ìâ©.
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 > |