Created
January 5, 2014 17:04
-
-
Save alexanderjeurissen/8270809 to your computer and use it in GitHub Desktop.
In javascript the fastest way to reverse a string is to first create a Char array , then reverse the array then join it.
In a recent project i wanted to revert strings and didn't want to duplicate "string value".split("").reverse().join("");
therefore i created a String.prototype so i can just call "string value".reverse();
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
String.prototype.reverse = function () { | |
return this.split("").reverse().join(""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment