Here you can find the source of pad(len, character)
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); } function update(){ var textArea = document.getElementById('text'); textArea.innerHTML = getTime();// w ww .j av a 2s . c om setTimeout(update,500); } function getTime(){ var time = new Date(); var hours = time.getHours(); var minutes = time.getMinutes(); var seconds = time.getSeconds(); return hours.pad(2,'0') + ':' + minutes.pad(2,'0') + ':' +seconds.pad(2,'0'); }
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, 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; };
String.prototype.pad = function(len, str){ var output = this.valueOf(); while(output.length < len){ output = str + output; return output; };
String.prototype.pad = function(length) { var str = this.toString(); while (str.length < length) { str = '0' + str; return str;
String.prototype.pad = function(length, character) if (!character) character = " "; var str = this; while (str.length < length) str += character; return str; }; ...
String.prototype.pad = function(length, character, direction) { var self = this; var STR_PAD_LEFT = 1; var STR_PAD_RIGHT = 2; var STR_PAD_BOTH = 3; if (typeof(length) == "undefined") { var length = 0; } if (typeof(character) == "undefined") { var character = ' '; } if (typeof(direction) == "undefined") { var direction = STR_PAD_RIGHT; } if (length + 1 >= self.length) { ...