Here you can find the source of pad(l, r)
// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved. ////from ww w.ja v a 2s.co m // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, // MA 02110-1301 USA String.prototype.pad = function(l, r) { if (r === undefined) { r = l if (!(this.substr(0, 2) == "0x" || /^\d+$/.test(this))) l = 0 } var ret = this.bin(); while (ret.length < l) ret = "\0" + ret while (ret.length < r) ret = ret + "\0" return ret; }
String.prototype.pad = function( digits ) { var x = this; while ( x.length < digits ) { x = '0' + x; return x; };
String.prototype.pad = function($char, $length) { var $result = this; while ($result.length < $length) { $result = $char + $result; return $result;
String.prototype.pad = function(l, r) { if (r === undefined) { r = l if (!(this.substr(0, 2) == "0x" || /^\d+$/.test(this))) l = 0 var ret = this.bin(); while (ret.length < l) ret = "\0" + ret ...
String.prototype.pad = function(l, s, t){ return s || (s = " "), (l -= this.length) > 0 ? (s = new Array(Math.ceil(l / s.length) + 1).join(s)).substr(0, t = !t ? l : t == 1 ? 0 : Math.ceil(l / 2)) + this + s.substr(0, l - t) : this; };
String.prototype.pad = function(l, s, t){ return s || (s = " "), (l -= this.length) > 0 ? (s = new Array(Math.ceil(l / s.length) + 1).join(s)).substr(0, t = !t ? l : t == 1 ? 0 : Math.ceil(l / 2)) + this + s.substr(0, l - t) : this; };
document.addEventListener("DOMContentLoaded", update); String.prototype.pad= function(len, character){ var s = ''; var character = character || '0'; var len = (len || 2)-this.length; return Array(len).join(character)+this; Number.prototype.pad = function(len, character){ return String(this).pad(len,character); ...
String.prototype.pad = function(len, str){ var output = this.valueOf(); while(output.length < len){ output = str + output; return output; };