📜  带前导零的 javascript pad - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:39.354000             🧑  作者: 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"