Created
September 13, 2014 20:05
-
-
Save mikesprague/7855784861d07cb0f3ae to your computer and use it in GitHub Desktop.
Adds a String function named endWith() to check and return the last character (if the function hasn't already been overridden)
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
if ( typeof String.prototype.endsWith !== 'function' ) { | |
String.prototype.endsWith = function( str ) { | |
return this.indexOf( str.toString(), this.length - str.length ) !== -1; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment