Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js number padding to number of characters

var n = 123

String("00000" + n).slice(-5); // returns 00123
("00000" + n).slice(-5); // returns 00123
("     " + n).slice(-5); // returns "  123" (with two spaces)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #number #padding #number #characters
ADD COMMENT
Topic
Name
2+4 =