Created
October 11, 2016 10:19
-
-
Save evolutionxbox/f1a6c9e1da159002bc4ae4a8fe6644d3 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
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