Javascript String lpad(pad_str, length)

Description

Javascript String lpad(pad_str, length)


// Pads strings to the left.
String.prototype.lpad = function(pad_str, length) {
  var str = this;
  while (str.length < length) str = pad_str + str;
  return str;/*  w w  w  .j  ava2 s  .c o m*/
}



PreviousNext

Related