๐Ÿ’พ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?