Skip to content

Instantly share code, notes, and snippets.

@evolutionxbox
Created October 11, 2016 10:19
Show Gist options
  • Save evolutionxbox/f1a6c9e1da159002bc4ae4a8fe6644d3 to your computer and use it in GitHub Desktop.
Save evolutionxbox/f1a6c9e1da159002bc4ae4a8fe6644d3 to your computer and use it in GitHub Desktop.
String Reverse
if (!String.prototype.reverse) {
String.prototype.reverse = function reverse() {
if (typeof this !== 'string') {
this.split('').reverse().join('');
} else {
throw new ReferenceError(this);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment