Format number

OSCC · JavaScript, String, Math · Oct 22, 2020

Formats a number using the local number format order.

const formatNumber = num => num.toLocaleString();
formatNumber(123456); // '123,456' in `en-US`
formatNumber(15675436903); // '15.675.436.903' in `de-DE`

Recommended snippets