javascript数字は0を補います.

319 ワード

<script type="text/javascript"> 

var pad = function(tbl) {

            return function(num, n){

                return (0 >= (n - ''+num.length)) ? num : (tbl[n] || (tbl[n] = Array(n + 1).join(0)))+num;

        }    

}([]);

alert(pad(233, 6));

</script>