如何將包含科學記數法的字串轉換成正確的 JavaScript 數值格式?


要轉換帶有科學記數法的字串,請使用 Number 函式。將值傳遞給此函式。

例子

您可以嘗試執行以下程式碼來將字串轉換為正確的數字格式 −

即時演示

<!DOCTYPE html>
<html>
   <body>
      <script>
         document.write("String with Scientific Notation converted below:<br>");
         document.write(Number("7.53245683E7"));
      </script>
   </body>
</html>

輸出

String with Scientific Notation converted below:
75324568.3

更新於:17-6 月-2020

1 千 + 瀏覽

開啟你的 職業

完成學位認證課程

開始
廣告
© . All rights reserved.