Skip to content

Instantly share code, notes, and snippets.

@pilotgeraldb
Created May 10, 2016 16:46
Show Gist options
  • Save pilotgeraldb/54c9bb81077cc45059a9cb22da5cb84d to your computer and use it in GitHub Desktop.
Save pilotgeraldb/54c9bb81077cc45059a9cb22da5cb84d to your computer and use it in GitHub Desktop.
javascript, utility string prototypes
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