Javascript String truncate(maxLength, suffix)

Description

Javascript String truncate(maxLength, suffix)


String.prototype.truncate = function(maxLength, suffix) {
  return this.length > maxLength + suffix.length
    ? this.substr(0, maxLength) + suffix
    : this;//from   w ww . j  a  v a  2  s  . c  o  m
}



PreviousNext

Related