1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 18:32:22 +00:00

fix: 为输出补充示例

This commit is contained in:
An Hongpeng 2021-04-20 20:03:08 +08:00 committed by GitHub
parent 3929f4f211
commit d09058f44e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -745,6 +745,8 @@ for (var key of Object.keys(someObject)) {
另一个方法是使用 Generator 函数将对象重新包装一下。
```javascript
const obj = { a: 1, b: 2, c: 3 }
function* entries(obj) {
for (let key of Object.keys(obj)) {
yield [key, obj[key]];