1
0
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:
ruanyf 2016-07-04 06:25:28 +08:00
parent c25565b70c
commit 0199e3182d
2 changed files with 6 additions and 2 deletions

View File

@ -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']

View File

@ -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;
} }
``` ```