How to avoid scientific notation for large numbers in JavaScript?

后端 未结 22 2361
無奈伤痛
無奈伤痛 2020-11-22 00:31

JavaScript converts a large INT to scientific notation when the number becomes large. How can I prevent this from happening?

22条回答
  •  野的像风
    2020-11-22 01:01

    You can use number.toString(10.1):

    console.log(Number.MAX_VALUE.toString(10.1));
    

    Note: This currently works in Chrome, but not in Firefox. The specification says the radix has to be an integer, so this results in unreliable behavior.

提交回复
热议问题