mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-25 03:02:21 +00:00
commit
d39c55d978
@ -745,6 +745,8 @@ for (var key of Object.keys(someObject)) {
|
|||||||
另一个方法是使用 Generator 函数将对象重新包装一下。
|
另一个方法是使用 Generator 函数将对象重新包装一下。
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
const obj = { a: 1, b: 2, c: 3 }
|
||||||
|
|
||||||
function* entries(obj) {
|
function* entries(obj) {
|
||||||
for (let key of Object.keys(obj)) {
|
for (let key of Object.keys(obj)) {
|
||||||
yield [key, obj[key]];
|
yield [key, obj[key]];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user