Wednesday, March 21, 2012

JavaScript zero padding

I don't know that javascript don't have 0 padding method looks like toString(2).
But some people found the answer.

Ex. 2digit padding
("0" + value).slice(-2)

Ex. 5digit padding
("0000"+value).slice(-5)

No comments:

Post a Comment