Files
leetcode/2619-array-prototype-last/2619-array-prototype-last.js
T

11 lines
212 B
JavaScript

/**
* @return {null|boolean|number|string|Array|Object}
*/
Array.prototype.last = function() {
return this.length === 0 ? -1 : this[this.length - 1]
};
/**
* const arr = [1, 2, 3];
* arr.last(); // 3
*/