Javascript String padLeft(length, char)

Description

Javascript String padLeft(length, char)

String.prototype.padLeft = function(length, char) {
  return Array(length - this.length + 1).join(char || " ") + this;
};

Javascript String padLeft(length, char)

String.prototype.padLeft = function (length, char) {
    if (char === void 0) { char = null; }
    return Array(length - String(this).length + 1).join(char || '0') + this;
};



PreviousNext

Related