> 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.last.md).

# arr.last

[JS](/web/js.md) ⟩ [object](/web/js/val/obj.md) ⟩ [built-in](/web/js/val/builtin.md) ⟩ [Array](/web/js/val/builtin/arr.md) ⟩ [custom properties](/web/js/val/builtin/arr/ext.md) ⟩ .last

{% tabs %}
{% tab title="💾 程式" %}

```javascript
// ⭐️ method 1:
Object.defineProperty(Array.prototype, 'last', {
    get() { return this[this.length - 1] }
})

// ⭐️ method 2:
Object.assign(Array.prototype, {
    get last() { return this[this.length - 1] }
});
```

{% endtab %}

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

* Object.[defineProperty](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)()
* Object.[defineProperties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties)()
* [Object.assign()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
  {% endtab %}

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

* object [getter/setter](/web/js/val/obj/prop/getter-setter.md)
* [shorthand property](/web/js/val/obj/prop/shorthand.md)
  {% endtab %}
  {% endtabs %}
