💾arr.last

JSobjectbuilt-inArraycustom 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