DEV Community

Discussion on: `at` coming soon to ECMAScript

Collapse
 
dewaldels profile image
Dewald Els

What ever happend to prototypes?

Array.prototype.last = function() {
  if (this.length > 0) {
    return this[this.length-1];    
  }
  return undefined
}

const items = ['What', 'ever', 'happened', 'to', 'prototypes'];
const lastItem = items.last();
console.log(lastItem);
Enter fullscreen mode Exit fullscreen mode