/** * @param int currentIndex **/ Array.prototype.nextIndex = function (currentIndex) { // currentIndex + 1 if in bounds, else 0 return currentIndex < this.length - 1 ? currentIndex + 1 : 0; }