📜  javascript print int withleading zeros - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:36.694000             🧑  作者: Mango

代码示例1
function padLeadingZeros(num, size) {
    var s = num+"";
    while (s.length < size) s = "0" + s;
    return s;
}
padLeadingZeros(57, 3);// "057"
padLeadingZeros(57, 4); //"0057"