Number.prototype.toLocaleString()
toLocaleString()
The method returns the string representation of this number in a specific locale.grammar:
numObj.toLocaleString([locales [, options]])
let num=12345678.98
num.toLocaleString()
//2,345,678.98
let num2=0.56
num2.toLocaleString('zh',{style:'percent'})
//'56%'
num2.toLocaleString('zh',{style:'currency',currency:'cny'})
//¥0.56
num2.toLocaleString('zh',{style:'currency',currency:'cny',currencyDisplay:'code'})
//'CNY 0.56'
num2.toLocaleString('zh',{style:'currency',currency:'cny',currencyDisplay:'name'})
//'0.56人民币'