Javascript String endsWith(pattern)
String.prototype.endsWith = function(pattern) { var d = this.length - pattern.length; return d >= 0 && this.lastIndexOf(pattern) === d; };
String.prototype.endsWith = function(pattern) { return (this.substr(this.length - pattern.length, pattern.length) === pattern); };