Skip to content

Instantly share code, notes, and snippets.

@JDMcKinstry
Created May 14, 2016 21:15
Show Gist options
  • Save JDMcKinstry/3960d6aecc21574ba53021fc53c48558 to your computer and use it in GitHub Desktop.
Save JDMcKinstry/3960d6aecc21574ba53021fc53c48558 to your computer and use it in GitHub Desktop.
Reverses a string
/* 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