function fix(num, length) {
return (‘‘ + num).length < length ? ((new Array(length + 1)).join(‘0‘) + num).slice(-length) : ‘‘ + num;
}
fix(1234, 8);
// "00001234"
fix(1234, 2);
// "1234"
2022-06-03 00:55:28
function fix(num, length) {
return (‘‘ + num).length < length ? ((new Array(length + 1)).join(‘0‘) + num).slice(-length) : ‘‘ + num;
}
fix(1234, 8);
// "00001234"
fix(1234, 2);
// "1234"
下一篇:html(网页)