Home  >  Article  >  Web Front-end  >  JavaScript Study Notes (4) Number Number Type_Basic Knowledge

JavaScript Study Notes (4) Number Number Type_Basic Knowledge

WBOY
WBOYOriginal
2016-05-16 17:52:331159browse

toFixed() method specifies the number of decimal places
toExponential() method uses scientific notation to express the number, and the parameter specifies the number of decimal places
toPrecision() method automatically determines whether to call the toFixed() or toExponential() method, and the parameter specifies The number of digits in all numbers

Copy code The code is as follows:

var num = 99;
alert(toFixed(2)); //99.00
alert(toExponential(1)); //9.0e 1
alert(toPrecision(1)); //9.0e 1
alert(toPrecision (2)); //99
alert(toPrecision(3)); //99.0
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn