Get to know MDN better
此頁面由社群從英文翻譯而來。了解更多並加入 MDN Web Docs 社群。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
reverse() 方法會原地(in place)反轉(reverse)一個陣列。陣列中的第一個元素變為最後一個,而最後一個元素則變成第一個。
反轉後的陣列。
reverse 方法將原地(in place)變換(transposes)呼叫此方法的陣列物件之元素至其顛倒的位置,改變原陣列後,並回傳此陣列之參考位址(reference)。
下列範例建立了一個包含三個元素的陣列 a,接著反轉此陣列。呼叫 reverse() 會回傳一個反轉後的原陣列 a 之參考。
| ECMAScript® 2027 Language Specification # sec-array.prototype.reverse |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年7月14日 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.