2619. Array Prototype Last ¶ TypeScript 1 2 3 4 5 6 7 8 9 10 11declare global { interface Array<T> { last(): T | -1; } } Array.prototype.last = function () { return this.length === 0 ? -1 : this[this.length - 1]; }; export {};