Convert numbers into comma separated format with two decimals in javascript
问题 I am trying to convert numbers into comma separated format with two decimal places for each and every number in javascript: My code: Number(parseFloat(n).toFixed(2)).toLocaleString('en'); This code doesn't show two decimal places (.00) for whole numbers. I am expecting following results for a set of numbers: 10000 => 100,00.00 123233.12 => 123,233.12 300000.5 => 300,000.50 Appreciate your answer, thanks. 回答1: You can use the minimumFractionDigits option of the toLocaleString function. //