UNPKG
gaga-js-utils
Version:
latest (1.0.0)
1.0.0
js tools
gaga-js-utils
/
src
/
thousandth
/
index.js
6 lines
•
190 B
JavaScript
View Raw
1
2
3
4
5
6
// 数字千分位分割
exports
.
thousandth
=
(
num
) =>
{
return
num.
toString
().
indexOf
(
"."
) !== -
1
? num.
toLocaleString
() : num.
toString
().
replace
(
/(\d)(?=(?:\d{3})+$)/g
,
"$1,"
); }