How to convert a String containing Scientific Notation to correct Javascript number format

前端 未结 6 1125
深忆病人
深忆病人 2020-11-27 06:41

I have a String e.g: \"4.874915326E7\". What is the best way to convert it to a javascript number format? (int or float)? if I try parseInt(), the E

6条回答
  •  囚心锁ツ
    2020-11-27 06:56

    You can also use + sign in front of your string to get a number.

    +"4.874915326E7" // == 48749153.26
    

提交回复
热议问题