Function: preZeroFill

preZeroFill(num, size): string

对整数进行前置补0

Parameters

Name Type Description
num number 需要补零的数值
size number 补零后的总位数

Returns

string

补零后的字符串

Description

将数字转换为指定位数的字符串,不足位数时在前面补0

Throws

当输入参数不是数字时抛出

Example

preZeroFill(12, 3); // => "012"
preZeroFill(1234, 3); // => "1234" (超过位数不补零)
ON THIS PAGE