Javascript casts floating point numbers to integers without cause

浪尽此生 提交于 2019-12-01 21:21:19

You've acknowledged that JavaScript only has a single Number type. As such, 1 is identical to 1.0.

If you need this for display purposes, then you should use toFixed.

1..toFixed(1); // "1.0"
number%1===0 

If that condition is true , it's integer, else it's float

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!