toLocaleString() formats the number into the string '1,234,567' with thousandth separator

1. toLocaleString(): Format the number into a string with thousands separators

2. Use toLocaleString() to convert numbers to percentages

var a = 1;
console.log(a.toLocaleString('zh',{style:'percent'}))
var b = 10;
console.log(b.toLocaleString('zh',{style:'percent'}))
var c = 2;
console.log(c.toLocaleString('zh',{style:'percent'}))
var d = 0.2;
console.log(d.toLocaleString('zh',{style:'percent'}))

Guess you like

Origin blog.csdn.net/tt18473481961/article/details/134412806