JavaScript番号toExponential()
例1
数値を指数表記に変換します。
let num = 5.56789;
let n = num.toExponential();
定義と使用法
toExponential()メソッドは、数値を指数表記に変換します。
例2
let num = 5.56789;
let n = num.toExponential(3);
構文
number.toExponential(x)
パラメーター
Parameter | Description |
---|---|
x | Optional. An integer between 0 and 20 representing the number of digits in the notation after the decimal point. If omitted, it is set to as many digits as necessary to represent the value |
戻り値
数値を指数表記として表す文字列。 |
ブラウザのサポート
Number.constructor
ECMAScript3(ES3)機能です。
ES3(JavaScript 1999)は、すべてのブラウザーで完全にサポートされています。
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |