String and Number padding in JavaScript by several methods, performance comparison

Ever now and then, output of formatted text, e.g. Bit patterns is needed, which requires you to pad a string or 'string'-Number. JavaScript casts pretty effortlessly between string Numbers and Integers, and some operations are easier performed as a Integer others as a string containing an Integer.

Benchmark via Chrome (as such slice seems to be an alias to subst, substring). Run the test yourself at JsPerf