JSFiddle - React, Tailwind, and code Playground

by Paul Esch-Laurent

JavaScript

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

var arr = [1, 2, 3, 4, 5];

alert(arr.last());