23.11.2014, 07:03, "Brendan Eich" <[email protected]>:

Axel Rauschmayer wrote:

 As an aside, I still feel that two concerns are mixed in a generator
 function:

 * The creation of the generator object. This is where the generator
 function is like a constructor and where you’d expect `this` to refer
 to the generator object.

Nope, not a constructor (and if you don't call with 'new', what is
'this', pray tell?).

Hmm... Interestingly, in Chrome if you do call it with 'new', 'this' would refer to a generator itself. But not in FireFox. I'm playing around with this example:
 
```
function *G() {
  console.log(this === x)
  yield 1
  console.log(this === x)
}
 
x = new G()
x.next()
x.next()
```
 
Shows "true, true" for V8 and "false, false" for FF engine.
 
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to