JavaScript Number toExponential ()
ví dụ 1
Chuyển một số thành ký hiệu hàm mũ:
let num = 5.56789;
let n = num.toExponential();
Định nghĩa và Cách sử dụng
Phương thức toExponential () chuyển đổi một số thành một ký hiệu mũ.
Ví dụ 2
let num = 5.56789;
let n = num.toExponential(3);
Cú pháp
number.toExponential(x)
Thông số
Parameter | Description |
---|---|
x | Optional. An integer between 0 and 20 representing the number of digits in the notation after the decimal point. If omitted, it is set to as many digits as necessary to represent the value |
Giá trị trả lại
Chuỗi, đại diện cho số dưới dạng ký hiệu hàm mũ. |
Hỗ trợ trình duyệt
Number.constructor
là một tính năng ECMAScript3 (ES3).
ES3 (JavaScript 1999) được hỗ trợ đầy đủ trong tất cả các trình duyệt:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |