If you’re a programmer, there’s a good chance you noticed the node.js left-pad fiasco of a few weeks back that temporarily broke most of the npm ecosystem. This blog doesn’t have an opinion on any of that. However, in the ensuing kerfluffle, severalpeopleobservedthat left-pad appears to be quadratic, and that is definitely this blog’s concern. If we look at the code, we see that the main loop looks like so: while (++i < len) { str = ch + str; } In most languages’ string implementati...