javascript convert int to float

前端 未结 2 1892
情话喂你
情话喂你 2020-12-08 01:52

I have a variable

var fval = 4;

now I want out put as 4.00

2条回答
  •  自闭症患者
    2020-12-08 02:15

    JavaScript only has a Number type that stores floating point values.

    There is no int.

    Edit:

    If you want to format the number as a string with two digits after the decimal point use:

    (4).toFixed(2)
    

提交回复
热议问题