Skip to content

Instantly share code, notes, and snippets.

@wayneashleyberry
Created October 2, 2012 17:26
Show Gist options
  • Save wayneashleyberry/3821399 to your computer and use it in GitHub Desktop.
Save wayneashleyberry/3821399 to your computer and use it in GitHub Desktop.
javascript endsWith function
String.prototype.endsWith = function (str) {
if (this.substr(-str.length) === str) {
return true;
}
return false;
};
@assertchris
Copy link

String.prototype.endsWith = function (str) {
    return this.substr(-str.length) === str;
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment