TypeScript: error when using parseInt() on a number

前端 未结 7 1124
心在旅途
心在旅途 2021-02-18 15:47

The JavaScript function parseInt can be used to force conversion of a given parameter to an integer, whether that parameter is a string, float number, number, etc.

相关标签:
7条回答
  • 2021-02-18 16:10

    There are different manifestations when negative numbers between 'Math.floor' and 'parseInt'.

    you should use this: 1.2 | 0

    or (1.2).toFixed(0)

    0 讨论(0)
提交回复
热议问题