leftZeroPad
var MANY_ZEROS = "000000000000000000"; function leftZeroPad(val, minLength) { if (typeof(val) != "string") val = String(val); return (MANY_ZEROS.substring(0, minLength - val.length)) + val; }
leftZeroPad(3, 2) ==> "03"
12388 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Steve Yen trimpath.com
var MANY_ZEROS = "000000000000000000"; function leftZeroPad(val, minLength) { if (typeof(val) != "string") val = String(val); return (MANY_ZEROS.substring(0, minLength - val.length)) + val; }