chop unused decimals with javascript

前端 未结 7 1047
鱼传尺愫
鱼传尺愫 2021-02-13 14:27

I\'ve got a currency input and need to return only significant digits. The input always has two decimal places, so:

4.00  ->  4
4.10  ->  4.1
4.01  ->           


        
相关标签:
7条回答
  • 2021-02-13 14:53

    I believe parseFloat() does this.

    parseFloat(4.00) // 4
    parseFloat(4.10) // 4.1
    parseFloat(4.01) // 4.01
    
    0 讨论(0)
提交回复
热议问题