limit the exponential notation decimal place to 4 in javascript

前端 未结 4 1393
深忆病人
深忆病人 2021-01-18 17:36

How to limit the decimal place to 4 in javascript with this type of values? the e is the exponent since I am using power of ten values. toFixed() doesn\'t seem

4条回答
  •  后悔当初
    2021-01-18 18:04

    You can use Math.round();

    Using Math.round(x) will round up or down to the nearest integer (using the classic .5 rule).

    You can pass in your own criteria and have it do decimal places. The link below has examples for 1, 2, and 3 decimal places.

    Here is the link

提交回复
热议问题