Javascript String endWith(s)

Description

Javascript String endWith(s)


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

Javascript String endWith(s)

String.prototype.endWith = function(s) {
  if (s == null || s == "" || this.length == 0 || s.length > this.length)
    return false;
  if (this.substring(this.length - s.length) == s)
    return true;//from   w w w  .  j  a  v  a 2  s. c  om
  else
    return false;
  return true;
}



PreviousNext

Related