Does JavaScript have a currency format specifier?

I was looking for a built-in JavaScript specifier to convert a number to currency, but I came to the conclusion that there is nothing built-in ...

So, doesn't JavaScript really have a currency format specifier?

Meanwhile, I did a google search and found the following lines of code do the job

.ToFixed(0).replace(/./g, function(c, i, a) {
    return i && c !== "." && ((a.length - i) % 3 === 0) ? ',' + c : c;
});

      

Any other / better way to convert a number to currency with some clear lines of code?

Please advise.

+3


source to share


1 answer


To parse numbers into a formatted string using Javascript.

In browser or node

numeraljs.com/

openexchangerates.github.io/accounting.js/

node only



github.com/joeferner/node -sf

github.com/fhellwig/strformat

Currency Format Assistant

github.com/Alir3z4/node -Money-currency

0


source







All Articles