Created
August 31, 2013 11:36
-
-
Save BartlomiejSkwira/6397696 to your computer and use it in GitHub Desktop.
Ends with
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::endsWith = (suffix) -> | |
| @indexOf(suffix, @length - suffix.length) isnt -1 | |
| #Doesn't create a substring | |
| #Uses native indexOf function for fastest results | |
| #Skip unnecessary comparisons using the second parameter of indexOf to skip ahead | |
| #Works in Internet Explorer | |
| #NO Regex complications | |
| #String.prototype.endsWith = function(suffix) { | |
| # return this.indexOf(suffix, this.length - suffix.length) !== -1; | |
| #}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment