จาวาสคริปต์เป็นเลขชี้กำลัง ()
ตัวอย่าง 1
แปลงตัวเลขเป็นสัญกรณ์เลขชี้กำลัง:
let num = 5.56789;
let n = num.toExponential();
ความหมายและการใช้งาน
toExponential() วิธีการแปลงตัวเลขเป็นสัญกรณ์เลขชี้กำลัง
ตัวอย่าง 2
let num = 5.56789;
let n = num.toExponential(3);
ไวยากรณ์
number.toExponential(x)
พารามิเตอร์
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 |
คืนมูลค่า
สตริงที่แสดงตัวเลขเป็นสัญกรณ์เลขชี้กำลัง |
รองรับเบราว์เซอร์
Number.constructor
เป็นคุณลักษณะ ECMAScript3 (ES3)
ES3 (JavaScript 1999) ได้รับการสนับสนุนอย่างสมบูรณ์ในเบราว์เซอร์ทั้งหมด:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |