====== JavaScript 원화 표시 ======
* description : JavaScript 원화 표시
* author : 오션
* email : shlim@repia.com
* lastupdate : 2023-01-26 Thu
\\
===== JavaScript 원화 표시 =====
const price = "14340";
let USDollar = new Intl.NumberFormat('en-Us', {
style: 'currency',
currency: 'USD'
});
console.log(`The foramtted version of ${price} is ${USDollar.format(price)}`);
// The foramtted version of 14340 is $14,340.00
const price1 = "3722407";
let result = new Intl.NumberFormat('ko-KR').format(price1);
console.log(result);
// 3,722,407
const price2 = 1270000;
let KRWon = new Intl.NumberFormat('ko-KR', {
style: 'currency',
currency: 'KRW'
});
let KRWonChanged = KRWon.format(price2);
console.log(typeof price2); // number
console.log(KRWonChanged); // ₩1,270,000
console.log(typeof KRWonChanged); // string
let original = KRWonChanged.substring(1).replace(/\,/g,'');
console.log(original); // 1270000
\\
Regex Test
\\
===== Ref Link ====
[[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat|Intl.NumberFormat]]\\
[[https://en.wikipedia.org/wiki/ISO_4217|ISO 4217 통화코드]]\\
[[https://en.wikipedia.org/wiki/Currency_symbol|Currency Symbol 통화 기호]]\\
{{tag> 오션 Javascript 원화_표시 Intl.NumberFormat}}