Node.js examples for String:Padding
Pad String from left and right
String.prototype.PadLeft = function (n, pad) { if (typeof pad === "undefined") { pad = "0"; } var t = ''; if (n > this.length) for (var i = 0; i < n - this.length; i++) t += pad;// w ww .jav a2 s .c o m return t + this; }; String.prototype.PadRight = function (n, pad) { var t = this; if (n > this.length) for (var i = 0; i < n - this.length; i++) t += pad; return t; };