4 ms·
Generators have to be marked as an asterisk as otherwise there's ambiguity; until recently 'yield' wasn't a reserved word, so it might be a variable name or any
by pimterry 12y ago
Generators have to be marked as an asterisk as otherwise there's ambiguity; until recently 'yield' wasn't a reserved word, so it might be a variable name or anything. Without disambiguating (via the *) old JavaScript can potentially break.
- untothebreach 12y ago'yield' was a reserved word in the ES4 spec, and a 'FutureReservedWord' in ES5 so if there is code that uses it as an identifier, it has been technically broken since 2008...
- gsnedders 12y agoWhat ES4 says is irrelevant. yield is only a FutureReservedWord in ES5 when within strict mode code; in non-strict code it is not a keyword, and plenty of code uses it and works in ES5 implementations.