Javascript String endsWith(s)

Description

Javascript String endsWith(s)


// <string>.endsWith( < string for comparason > )

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

Javascript String endsWith(s)

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

Javascript String endsWith(s)

String.prototype.endsWith = function(s){
    return this.indexOf(s) == this.length - s.length;
};



PreviousNext

Related