A shorter version of what @chaiguy posted:
Array.prototype.last = function() { return this[this.length - 1]; } Reading the -1 index returns undefined already.
EDIT:
These days the preference seems to be using modules and to avoid touching the prototype or using a global namespace.
export function last(array) { return array[array.length - 1]; }