如何將包含科學計數法的字串轉換為正確的 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-Jun-2020

1K+ 瀏覽量

開啟你的 職業生涯

透過完成課程獲得認證

開始學習
廣告
© . All rights reserved.