첫번째 방법
export const priceFormatter = (price) => {
const comma = (price) => {
const price2 = String(price)
return price2.replace(/(\d)(?=(?:\d{3})+(?!\d))/g, '$1,')
}
const uncomma = (price) => {
const price3 = String(price)
return price3.replace(/[^\d]+/g, '')
}
return comma(uncomma(price))
}
두번째 방법
Array.prototype.toLocaleString()
참조: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString
http://www.devdic.com/javascript/refer/native/method:1344/toLocaleString()
나의 이글이 누군가에게 가취있기를..