2619. Array Prototype Last
All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : July 10, 2024
Last updated : July 10, 2024
Related Topics : N/A
Acceptance Rate : 74.08 %
/**
* @return {null|boolean|number|string|Array|Object}
*/
Array.prototype.last = function() {
if (this.length == 0) {
return -1;
}
return this[this.length - 1];
};
/**
* const arr = [1, 2, 3];
* arr.last(); // 3
*/