๐พ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] }
});Object.defineProperty()
Object.defineProperties()
Last updated
Was this helpful?