How to use JavaScript to add 0 to less than 4 digits after the decimal point

var demo = 5; alert
(demo.toFixed(4));

toFixed( number ), format the number as a string with number decimal places. Note that the original value must be a numerical value, such as var demo = 1; demo = demo.toFixed(4); and var demo='1'; demo = demo.toFixed(4); will not work.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325514233&siteId=291194637