Skip to content

Instantly share code, notes, and snippets.

@matthewmorrone
Created December 6, 2014 23:23
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 matthewmorrone/006cef5f1e1b54fd2344 to your computer and use it in GitHub Desktop.
Save matthewmorrone/006cef5f1e1b54fd2344 to your computer and use it in GitHub Desktop.
Array.prototype.define("swap", function(a, b) {
// this[a] = this.splice(b, 1, this[a])[0]; // slower but prettier
var tmp = this[a];
this[a] = this[b];
this[b] = tmp;
return this;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment