Skip to content

Instantly share code, notes, and snippets.

@tkatochin
Last active December 22, 2015 06:59
Show Gist options
  • Save tkatochin/6435188 to your computer and use it in GitHub Desktop.
Save tkatochin/6435188 to your computer and use it in GitHub Desktop.
Stringの startsWith, endsWith
String.prototype.startsWith = function(prefix) {
return this.lastIndexOf(prefix, 0) == 0;
};
String.prototype.endsWith = function(suffix) {
return this.lastIndexOf(suffix) == this.length-suffix.length;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment