mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-24 18:32:22 +00:00
Merge branch 'gh-pages' of github.com:ruanyf/es6tutorial into gh-pages
This commit is contained in:
commit
41efa95b18
@ -728,7 +728,7 @@ Array(3) // [, , ,]
|
||||
|
||||
ES5 对空位的处理,已经很不一致了,大多数情况下会忽略空位。
|
||||
|
||||
- `forEach()`, `filter()`, `every()` 和`some()`都会跳过空位。
|
||||
- `forEach()`, `filter()`, `reduce()`, `every()` 和`some()`都会跳过空位。
|
||||
- `map()`会跳过空位,但会保留这个值
|
||||
- `join()`和`toString()`会将空位视为`undefined`,而`undefined`和`null`会被处理成空字符串。
|
||||
|
||||
@ -742,6 +742,9 @@ ES5 对空位的处理,已经很不一致了,大多数情况下会忽略空
|
||||
// every方法
|
||||
[,'a'].every(x => x==='a') // true
|
||||
|
||||
// reduce方法
|
||||
[1,,2].reduce((x,y) => return x+y) // 3
|
||||
|
||||
// some方法
|
||||
[,'a'].some(x => x !== 'a') // false
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user