Skip to content

Instantly share code, notes, and snippets.

@hallison
Last active February 25, 2019 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hallison/ac992b6eb677ed7ad9da21056c591fd6 to your computer and use it in GitHub Desktop.
Save hallison/ac992b6eb677ed7ad9da21056c591fd6 to your computer and use it in GitHub Desktop.
Order list items in Array
Array.prototype.orderItems = function(newer, older) {
var list = new Array(...this)
return list.splice(newer - 1, 0, ...list.splice(older, 1))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment