Created
December 6, 2014 23:23
-
-
Save matthewmorrone/006cef5f1e1b54fd2344 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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