Created
May 14, 2016 21:15
-
-
Save JDMcKinstry/3960d6aecc21574ba53021fc53c48558 to your computer and use it in GitHub Desktop.
Reverses a string
This file contains hidden or 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
/* String.prototype.reverse */ | |
;(function() { // Reverses a string | |
var name = "reverse"; | |
function reverse() { for (var a = "", g = this.length - 1; 0 <= g; g--) a += this[g]; return a; } | |
Object['defineProperty'] && !String.prototype.hasOwnProperty(name) | |
? Object.defineProperty(String.prototype, name, { value: reverse }) : String.prototype[name] = unique; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment