what bothers me the zeroth most about leftpad is that the criticisms of this thread are not in any way specific to leftpad
and what actually got me thinking about this was the YAML processor which ships by default in Ruby and is used in virtually every Rails application
this is the code for leftpad
function leftpad (str, len, ch) {
str = String(str);
var i = -1;
if (!ch && ch !== 0) ch = ' ';
len = len - str.length;
while (++i < len) {
str = ch + str;
}
return str;
}