ES6 - Number.parseInt()



此方法解析字串引數並返回指定基數的整數。

語法

Number.parseInt(string,[ radix ])

引數

  • 字串 − 要解析的值
  • 基數 − 介於 2 和 36 之間的整數,表示基數。

返回值

字串的整數表示。

示例

console.log(Number.parseInt("10"));
console.log(Number.parseInt("10.23"));

輸出

10
10
廣告
© . All rights reserved.