> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/js/val/builtin/arr/ext/arr.reversed.md).

# arr.reversed()

[JS](/web/js.md) ⟩ [objects](/web/js/val/obj.md) ⟩ [Array](/web/js/val/builtin/arr.md) ⟩[ methods](/web/js/val/builtin/arr/method.md) ⟩ reversed()

{% tabs %}
{% tab title="💾 程式" %}
:floppy\_disk: replit: [array.reversed()](https://replit.com/@pegasusroe/arrayreversed#index.js)

```javascript
// 🔸 array.reversed()
// note: array.reverse() will reverse the array IN PLACE.
Array.prototype.reversed = function(){
    const [first, ...rest] = this;
    return first === undefined ? [] : [...rest.reversed(), first];
};

```

💈範例：

```javascript
const a = [1,2,3,4];
a.reversed()       // [ 4, 3, 2, 1 ]
```

{% endtab %}

{% tab title="📘 手冊" %}

* [Array.prototype.reverse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse)
  {% endtab %}

{% tab title="👥 相關" %}

* [str.reverse()](/web/js/val/prim/str/method/str.reverse.md)
* [recursion](/web/appendix/algorithms/recursion.md)
  {% endtab %}
  {% endtabs %}
