Skip to content

Instantly share code, notes, and snippets.

@michaelward82
Created March 31, 2014 13:11
Show Gist options
  • Save michaelward82/9891934 to your computer and use it in GitHub Desktop.
Save michaelward82/9891934 to your computer and use it in GitHub Desktop.
Javascript Array: Get the next existing index
/**
* @param int currentIndex
**/
Array.prototype.nextIndex = function (currentIndex) {
// currentIndex + 1 if in bounds, else 0
return currentIndex < this.length - 1 ? currentIndex + 1 : 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment