Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to get four digits after the decimal point of javascript?
How to get four digits after the decimal point of javascript?
Js provides the corresponding function, that is, the fixed (n) method. Parameter n indicates how many decimal places are reserved.

For example:

var? Answer? = 123.456789;

alert(a . to fixed(4)); //? Round to four decimal places.

//? Rounds a number and truncates n decimal places.

getResult(num,n)? {

Return? Fixed quantity (n);

} Note:

What time? Throw an exception when n is too small or too large? Range error. Normal range is.

When the object calling this method is not. Number? When you throw it? TypeError? Not normal.