Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intl.NumberFormat "compact" doesn't return correctly formated number

Following this example I've tried to get large numbers formatted more compact:

console.log(
    new Intl.NumberFormat(
        'en-GB', 
        { notation: "compact" , compactDisplay: "short" }
    ).format(987654321)
);

But my result, in both Firefox and Chrome, differs. I get "987,654,321" instead of the expected "988M" as in the example. Anyone know why this is the case and how I might be able to fix it?

like image 699
spekulatius Avatar asked Nov 07 '22 08:11

spekulatius


1 Answers

I faced the same issue and I tried to look for a logical reason and I found this official documentation : https://v8.dev/features/intl-numberformat#notation And as I understood 'compact' option it's still not fully supported

like image 200
Schnitter Avatar answered Nov 15 '22 11:11

Schnitter