💾arr.last
JS ⟩ object ⟩ built-in ⟩ Array ⟩ custom properties ⟩ .last
// ⭐️ 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] }
});
Last updated
Was this helpful?