Javascript Number zf(len)

Description

Javascript Number zf(len)


/**/*  w  w w  . j a v a 2 s.  c  o m*/
 * @author Dustin Moorman <dustin.moorman@gmail.com>
 * A little type augmentation for methods I use in the
 * chronograph.
 */

/**
 * Give Number a zero fill method.
 * @param len
 * @return String
 */
Number.prototype.zf = function(len){

    if(isNaN(len)) len = 2;

    return (this + '').pad(len, '0');
};



PreviousNext

Related