Last active
May 19, 2016 18:10
-
-
Save daronwolff/833d14a1c420a723dd54f7d59567e8a6 to your computer and use it in GitHub Desktop.
Javascript - Invert array position elements manually. I created this little code to my friends in Kwan
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
"use strict"; | |
if (!Array.prototype.reverseOrder) { | |
Array.prototype.invertir = function() { | |
var inverted = []; | |
for (var i = this.length - 1; i >= 0; i--) { | |
inverted[this.length - (i + 1)] = this[i]; | |
} | |
return inverted; | |
} | |
} | |
var b = Array("1", "2", "3") | |
console.log(b.invertir()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment