Posted By

szsk on 08/02/06


Tagged

javascript array String numeric


Versions (?)

string_pad


 / Published in: JavaScript
 

URL: http://d.hatena.ne.jp/brazil/20060721/1153489937

  1. function pad(str, len, ch){return new Array(len-(''+str).length+1).join(ch) + str}
  2.  
  3. alert(pad(56, 4, '0')); // 0056

Report this snippet  

You need to login to post a comment.