How get digits after the decimal points in NumberFormat?

Solution 1:

Add a maximumFractionDigits property to the options with the number of fractional digits you want to permit.

const CurrencyFormat = (amount = 0, currency = 'eur', digitLength = 'latn') => {
  return new Intl.NumberFormat('en-GB', {
    style: 'currency',
    currency: currency,
    numberingSystem: digitLength,
    maximumFractionDigits: 20,
  }).format(amount)
};

console.log(CurrencyFormat(56.123456, 'eur', 'fullwide'));
console.log(CurrencyFormat(56.123456));

I found this by finding the word MaximumFractionDigits in the specification and discovering that it's a property on instances which can be set through the options object..

Solution 2:

maximumFractionDigits helped to get decimal

const CurrencyFormat = (amount = 0, currency = 'eur') => {
  return new Intl.NumberFormat('en-GB', {
    style: 'currency',
    currency: currency,
    maximumFractionDigits: amount.toString().length,
  }).format(amount)
};

console.log(CurrencyFormat(56.123456, 'eur', 'fullwide'));
console.log(CurrencyFormat(56.123456));