04-指数符号
16.1.2 指数符号
如果希望用指数形式来显示数字,可以用:Number.prototype.toExponential:
const x = 3800.5;
x.toExponential(4); // "3.8005e+4";
x.toExponential(3); // "3.801e+4";
x.toExponential(2); // "3.80e+4";
x.toExponential(1); // "3.8e+4";
x.toExponential(0); // "4e+4";
与 Number.prototype.toFixed 一样,结果也是四舍五入的。指定的精度是小数位的个数。