Here is a contrived example with respect to better understanding "best practices" in JavaScript. For example, I want to introduce a new method to the Array prototype that will return last element.
[1,2,3].last() // 3
But extending the basic Prototype is considered bad practice (except in the case of polyfills):
Array.prototype.last = function(){
return this[this.length - 1];
}
How can I achieve this without it being "bad practice"?