[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential [Back]  [Original]

Number.prototype.toExponential() - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

Number.prototype.toExponential()

Baseline

20157

toExponential() Number

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"

js
toExponential()
toExponential(fractionDigits)

fractionDigits

Number ( 1 fractionDigits )

RangeError

fractionDigits 0 100

TypeError

Number

fractionDigits

toExponential 1

fractionDigits fractionDigits toFixed() toExponential

toExponential

js
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