mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-24 18:32:22 +00:00
docs(array): fix type
This commit is contained in:
parent
c25565b70c
commit
0199e3182d
@ -414,7 +414,7 @@ ES5对空位的处理,已经很不一致了,大多数情况下会忽略空
|
|||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// forEach方法
|
// forEach方法
|
||||||
[,'a'].forEach((x,i) => log(i)); // 1
|
[,'a'].forEach((x,i) => console.log(i)); // 1
|
||||||
|
|
||||||
// filter方法
|
// filter方法
|
||||||
['a',,'b'].filter(x => true) // ['a','b']
|
['a',,'b'].filter(x => true) // ['a','b']
|
||||||
|
@ -873,7 +873,11 @@ function* entries(obj) {
|
|||||||
|
|
||||||
// 非Generator函数的版本
|
// 非Generator函数的版本
|
||||||
function entries(obj) {
|
function entries(obj) {
|
||||||
return (for (key of Object.keys(obj)) [key, obj[key]]);
|
let arr = [];
|
||||||
|
for (key of Object.keys(obj)) {
|
||||||
|
arr.push([key, obj[key]]);
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user