Skip to content

Instantly share code, notes, and snippets.

@alexanderjeurissen
Created January 5, 2014 17:04
Show Gist options
  • Save alexanderjeurissen/8270809 to your computer and use it in GitHub Desktop.
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();
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