Pad Javascript String With A Character - gecko-8/devwiki GitHub Wiki

  • On new browsers simple use the .padStart method of the string object.
    myString.padStart(4, '0')

This will pad myString with 0s to a length of 4. E.G.
'24' => '0024'