Created
May 10, 2016 16:46
-
-
Save pilotgeraldb/54c9bb81077cc45059a9cb22da5cb84d to your computer and use it in GitHub Desktop.
javascript, utility string prototypes
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.prototype.startsWith = function(str) | |
{ | |
return (this.indexOf(str) === 0); | |
}; | |
String.prototype.contains = function(str) | |
{ | |
return (this.indexOf(str, 0) !== -1); | |
}; | |
String.prototype.endsWith = function(str) | |
{ | |
return (this.match(str+"$") == str); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment