Javascript String newEndWith(s)

Description

Javascript String newEndWith(s)


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

var str = 'aabbcc';
console.log(str.newEndWith('bcc'));
// true//from  ww w  .j av a  2s  .c  om



PreviousNext

Related