[JS] 숫자 천단위 쉼표 찍기

hyeonze·2022년 2월 7일

인턴쉽

목록 보기
2/8

자주 사용되나 기억하기 어려워서 메모

const number = 1000000;
const string = number.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");
// '1,000,000'
Number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
profile
Advanced thinking should be put into advanced code.

0개의 댓글