Hàm toExponential() của đối tượng Number trả về chuỗi biểu diễn số ở ký hiệu mũ (exponential notation).
Cú pháp
Cú pháp của nó như sau:
num.toExponential(fractionDigits)
Ví dụ
<html> <head> <title>Ví dụ JavaScript</title> </head> <body> <script type="text/javascript"> var num = 77.1234; document.write( num.toExponential(4)); document.write("<br>"); var num = 77.1234; document.write(num.toExponential()); document.write("<br>"); var num = 77.1234; document.write(num.toExponential(0)); </script> </body> </html>
Kết quả
7.7123e+1 7.71234e+1 8e+1