Javascript String endsWith(pattern)

Description

Javascript String endsWith(pattern)


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

Javascript String endsWith(pattern)

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



PreviousNext

Related