Generator 的 this
function* hello(){this.name = "world";this.say = function(){return this; // otherThis}return this; // oneThis}let gen = hello.call(hello.prototype); // 必须let oneThis = gen.next().value;let otherThis = gen.say();oneThis === otherThis // falseotherThis === gen // trueoneThis === otherThis.__proto__ // trueoneThis === hello.prototype // trueotherThis instanceof hello // trueoneThis.name // worldotherThis.name // world
由上代码可以看出两个各方式返回的this并不是都代表hello函数的实例;其中oneThis指向hello函数的原型hello.prototype,otherThis指向hello的实例
