JavaScript Number toExponential() method
- เพจก่อนหน้า prototype
- เพจต่อไป toFixed()
- กลับไปยังเพจขึ้นหนึ่ง คู่มืออ้างอิง JavaScript Number
definition and usage
toExponential()
The method converts the number to exponential notation.
instance
Example 1
let num = 5.56789; let n = num.toExponential(3);
Example 2
Convert the number to exponential notation:
let num = 5.56789; let n = num.toExponential();
syntax
number.toExponential(digits)
parameter
parameter | description |
---|---|
digits |
Optional. An integer between 0 and 20, specifying the number of decimal places in exponential notation. If omitted, it is set to the number of digits required to represent the value. |
return value
type | description |
---|---|
string | represent the number in exponential notation. |
technical details
return value
Returns the string representation of Number using exponential notation, where there is one digit before the decimal point and digits digit. The decimal part of the number will be rounded and, if necessary, padded with 0 to reach the specified length.
thrown
exception | description |
---|---|
RangeError |
when digits Exception thrown when too small or too large. Values between 0 and 20 do not trigger this exception. Some implementations support a wider or narrower range of values. |
TypeError | Exception thrown when the object called this method is not Number. |
browser support
Number.constructor
เป็นคุณสมบัติของ ECMAScript3 (ES3)
ทุกบราวเซอร์สนับสนุน ES3 (JavaScript 1999):
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
สนับสนุน | สนับสนุน | สนับสนุน | สนับสนุน | สนับสนุน | สนับสนุน |
- เพจก่อนหน้า prototype
- เพจต่อไป toFixed()
- กลับไปยังเพจขึ้นหนึ่ง คู่มืออ้างอิง JavaScript Number