• towerful
    link
    fedilink
    arrow-up
    6
    ·
    9 months ago

    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!