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()
Object.assign()
object getter/setter
shorthand property
Last updated 1 year ago