mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-15 09:57:09 +00:00
Time: 49 ms (65.84%), Space: 48.5 MB (76.08%) - LeetHub
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
Reference in New Issue
Block a user