Number and Currency Formatting in JavaScript using Intl.NumberFormat
Number and Currency Formatting in JavaScript using Intl.NumberFormat
dev.to Number and Currency Formatting in JavaScript using Intl.NumberFormat
While this post does not by any means aim to cover all the amazing things you can do with...
You're viewing a single thread.
View all comments
5
comments
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!
6 0 Reply100% Agree
1 0 Reply