Created
May 16, 2015 14:36
-
-
Save mofas/03294cf6e4f83e6c8bb7 to your computer and use it in GitHub Desktop.
String reverse
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(){ | |
var m = this.length >> 1, | |
f = this.substring(0,m), | |
t = this.substring(m,this.length); | |
return m == 0 ? t : this.reverse.apply(t) + this.reverse.apply(f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment