4 ms·
This can't be about backwards compatibility. If it was, they wouldn't have been able to add 'yield, 'await' etc. I don't agree the keyword "generator" would ha
by callum85 12y ago
This can't be about backwards compatibility. If it was, they wouldn't have been able to add 'yield, 'await' etc.
I don't agree the keyword "generator" would have been ideal. It wouldn't work when using 'enhanced object literals' [1], where you can declare a method without even using the keyword "function". In this case, if you want the method to be a generator, you can just put an asterisk in front of its name, so it's consistent with the "function*" syntax.
[1] https://babeljs.io/docs/learn-es6/#enhanced-object-literals https://babeljs.io/docs/learn-es6/#enhanced-object-literals
- tlrobinson 12y agoFYI, "yield" has been a reserved word since ES5 and "await" is becoming reserved in ES6 (for eventual use in ES7): https://mathiasbynens.be/notes/reserved-keywords https://mathiasbynens.be/notes/reserved-keywords It seems like a word must be reserved for at least one ES version prior to it being used.