| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential | [Back] [Original] |
Get to know MDN better
function expo(x, f) {
return Number.parseFloat(x).toExponential(f);
}
console.log(expo(123456, 2));
// : "1.23e+5"
console.log(expo("123456"));
// : "1.23456e+5"
console.log(expo("oink"));
// : "NaN"
toExponential()
toExponential(fractionDigits)
Number ( 1 fractionDigits )
RangeErrorfractionDigits 0 100
TypeErrorfractionDigits
toExponential 1
fractionDigits fractionDigits toFixed() toExponential
const numObj = 77.1234;
console.log(numObj.toExponential()); // 7.71234e+1
console.log(numObj.toExponential(4)); // 7.7123e+1
console.log(numObj.toExponential(2)); // 7.71e+1
console.log((77.1234).toExponential()); // 7.71234e+1
console.log((77).toExponential()); // 7.7e+1
| ECMAScript 2027 LanguageSpecification # sec-number.prototype.toexponential |
| Web Proxy Viewer | New URL | Original Page |