@[email protected] to Web [email protected] • 9 months agoNumber and Currency Formatting in JavaScript using Intl.NumberFormatdev.toexternal-linkmessage-square5fedilinkarrow-up111arrow-down11
arrow-up110arrow-down1external-linkNumber and Currency Formatting in JavaScript using Intl.NumberFormatdev.to@[email protected] to Web [email protected] • 9 months agomessage-square5fedilink
minus-square@[email protected]linkfedilink5•9 months agoIts worth creating an Intl formatter outside of a loop, then applying it inside the loop - if you are formatting everything in the loop the same. const formatter = Intl.NumberFormat(/* options */); return items.map(item => { return { ...item, total: formatter.format(item.total) } }); …Or however you choose to mutate an array. Well, certainly it used to be. Not sure if that is still the case!
Its worth creating an Intl formatter outside of a loop, then applying it inside the loop - if you are formatting everything in the loop the same.
const formatter = Intl.NumberFormat(/* options */); return items.map(item => { return { ...item, total: formatter.format(item.total) } });
…Or however you choose to mutate an array.
Well, certainly it used to be. Not sure if that is still the case!
100% Agree