Fill zero for number - Node.js Number

Node.js examples for Number:Format

Description

Fill zero for number

Demo Code

$(function() {/*from w w w .j  av a  2s. c o  m*/
    Number.prototype.fillZero = function(n) {
        var r = this.toString().split('');
        while (r.length < n) {
            r.unshift('0');
        }
        return r.join('');
    };
    Array.prototype.clone = function() {
        return Array.apply(null, this);
    };
});

Related Tutorials