padStart or padEnd are often used with numbers
so you have to do one of
String(num).padStart(n, c)
`${num}`.padStart(n, c)
It would be easier if this method is ported to numbers as well
padStart or padEnd are often used with numbers
so you have to do one of
String(num).padStart(n, c)
`${num}`.padStart(n, c)
It would be easier if this method is ported to numbers as well
There is also a 3rd option of num.toString().padStart(n, c)
.
For more control over formatting numbers this is also Intl.NumberFormat:
45..toLocaleString(βen-usβ, {minimumIntegerDigits: 6 });
> 000,045