修改object/assign

This commit is contained in:
Ruan Yifeng
2014-12-23 08:55:24 +08:00
parent 8b3d0a575d
commit ef6bd9d6fa
2 changed files with 227 additions and 74 deletions
+26
View File
@@ -499,3 +499,29 @@ result
// ['a', 'b', 'c', 'd', 'e', 'f', 'g']
```
## 作为对象属性的Generator函数
如果一个对象的属性是Generator函数,可以简写成下面的形式。
```javascript
let obj = {
* myGeneratorMethod() {
···
}
};
```
它的完整形式如下,两者是等价的。
```javascript
let obj = {
myGeneratorMethod: function* () {
···
}
};
```