Typescript / javascript number format

Date: 2021-11-30

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat

//  options:
interface NumberFormatOptions {
    localeMatcher?: string;
    style?: string;
    currency?: string;
    currencyDisplay?: string;
    currencySign?: string;
    useGrouping?: boolean;
    minimumIntegerDigits?: number;
    minimumFractionDigits?: number;
    maximumFractionDigits?: number;
    minimumSignificantDigits?: number;
    maximumSignificantDigits?: number;
}


const numberFormatter = new Intl.NumberFormat("nl-NL", { maximumFractionDigits: 2 });
export function formatNumber(x: number): string {
    return numberFormatter.format(x);
}
57450cookie-checkTypescript / javascript number format