number方法 toLocaleString() 与 toString() 的区别

1.toLocaleString(),当数字是四位数及以上时,从右往左数,每三位用分号隔开,并且小数点后只保留三位;而toString()单纯将数字转换为字符串。

2.toLocaleString(),当目标是标准时间格式时,输出简洁年月日,时分秒;而toString()输出国际表述字符串。

 

posted @ 2022-02-24 21:58  月光怀古  阅读(276)  评论(0)    收藏  举报