JavaScript Number toExponential() Method
toExponential() 方法是用來將數字轉型為科學記號表示法 (字串型態)。
語法:
numObj.toExponential([fractionDigits]);
參數可有可無,用來指定小數點後要幾位數。
用法:
const numObj = 77.1234;
numObj.toExponential(); // 7.71234e+1
numObj.toExponential(4); // 7.7123e+1
numObj
.toExponential(2)(
// 7.71e+1
77.1234
)
.toExponential()(
// 7.71234e+1
77
)
.toExponential(); // 7.7e+1