Javascript String lastChar(new_char)

Description

Javascript String lastChar(new_char)


String.prototype.lastChar = function(new_char){
  if(typeof new_char === 'undefined'){
    return this.charAt(this.length-1);
  }else if(typeof new_char === "string"){
    return this.slice(0, this.length-1) + new_char;
  }/*ww  w  . j  a  va  2s  .co m*/
};



PreviousNext

Related