mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2024-04-21 12:32:22 +00:00
修改docs/number
This commit is contained in:
@@ -37,6 +37,18 @@ Number.isNaN("NaN") // false
|
||||
|
||||
ES6将全局方法parseInt()和parseFloat(),移植到Number对象上面,行为完全保持不变。
|
||||
|
||||
```javascript
|
||||
|
||||
// ES5的写法
|
||||
parseInt("12.34") // 12
|
||||
parseFloat('123.45#') // 123.45
|
||||
|
||||
// ES6的写法
|
||||
Number.parseInt("12.34") // 12
|
||||
Number.parseFloat('123.45#') // 123.45
|
||||
|
||||
```
|
||||
|
||||
这样做的目的,是逐步减少全局性方法,使得语言逐步模块化。
|
||||
|
||||
## Number.isInteger()和安全整数
|
||||
|
||||
Reference in New Issue
Block a user