반응형
(1+'').padStart(2,'0')
(1).toLocaleString('en-US',{minimumIntegerDigits:2}) 동작함
1.toLocaleString('en-US',{minimumIntegerDigits:2}) 에러남
How to format numbers by prepending 0 to single-digit numbers?
I want to format a number to have two digits. The problem is caused when 0–9 is passed, so I need it to be formatted to 00–09. Is there a number formatter in JavaScript?
stackoverflow.com
반응형
'js > js syntax' 카테고리의 다른 글
[다중정렬]data.sort((a, b) => a.price - b.price || a.name.localeCompare(b.name)); (0) | 2024.03.22 |
---|---|
{...{id:1,value:일},id:2} ->젤 뒤에 오는 2가 앞의 1을 덮어버림, 앞에 위치한 값은 없어짐 (0) | 2024.02.07 |
javascript true/false (0) | 2022.08.31 |
js reduce function (0) | 2022.08.22 |
js empty array check: arr?.length===0 (객체이면 arr.length는 undefined) (0) | 2022.07.11 |