이 메서드는 지수 표기법으로 숫자 개체를 나타내는 문자열을 반환합니다. 다음은 구문입니다:
number.toExponential( [fractionDigits] )
fractionDigits 매개변수는 소수점 이하 자릿수를 지정하는 정수입니다.
예시
다음 코드를 실행하여 JavaScript에서 Number.toExponential() 메서드를 사용하는 방법을 배울 수 있습니다.
<html>
<head>
<title>JavaScript Method toExponential()</title>
</head>
<body>
<script>
var num=77.1234;
var val = num.toExponential();
document.write("num.toExponential() is : " + val );
document.write("<br />");
val = num.toExponential(4);
document.write("num.toExponential(4) is : " + val );
document.write("<br />");
val = num.toExponential(2);
document.write("num.toExponential(2) is : " + val);
document.write("<br />");
val = 77.1234.toExponential();
document.write("77.1234.toExponential()is : " + val );
document.write("<br />");
val = 77.1234.toExponential();
document.write("77 .toExponential() is : " + val);
</script>
</body>
</html>