What is `this` inside a new-invoked generator?

2015-03-23 Thread Axel Rauschmayer
Question: what does the following code snippet log in the last line? ```js function* gen() { yield this; } let genObj = new gen(); let [_this] = genObj; console.log(_this === genObj); // ??? ``` I’m finding three answers: 1. The spec says [1] that any reference to `this` in a generator

Re: What is `this` inside a new-invoked generator?

2015-03-23 Thread André Bargull
Question: what does the following code snippet log in the last line? ```js function* gen() { yield this; } let genObj = new gen(); let [_this] = genObj; console.log(_this === genObj); // ??? ``` I’m finding three answers: 1. The spec says [1] that any reference to `this` in a generator