JSFiddle - React, Tailwind, and code Playground

JavaScript

Array.prototype.at = function(index) {
    return index > this.length ? this[0] : this[index];
};

var list = ['first', 'second', 'third'];

document.write(list.at(1));
document.write('<br />');
document.write(list.at(5));