Class: Number

Number

The JavaScript Number object.

new Number()

Source:
See:

Methods

toPaddedString(length, radix)

Returns a string representation of the number padded with leading 0s so that the string's length is at least equal to length. Takes an optional radix argument which specifies the base to use for conversion.

Parameters:
Name Type Argument Default Description
length Number

The minimum length for the resulting string.

radix Number <optional>
10

Defines which base to use for representing the numeric value. Must be an integer between 2 and 36.

Source:
Example
(255).toPaddedString(4);     // "0255"
(255).toPaddedString(4, 16); // "00ff"
(25589).toPaddedString(4);   // "25589"
(3).toPaddedString(5, 2);    // "00011"
(-3).toPaddedString(5, 2);   // "-0011"