Converts a number to a decimal mark formatted string.
- Use
Number.prototype.toLocaleString()
to convert the number to decimal mark format.
代码实现
const toDecimalMark = num => num.toLocaleString('en-US');
toDecimalMark(12305030388.9087); // '12,305,030,388.909'
翻译自:https://www.30secondsofcode.org/js/s/number-to-decimal-mark