Skip to content
Advertisement

Can I use ES6’s arrow function syntax with generators? (arrow notation)

That is, how do I express

function *(next) {}

with arrow syntax? I’ve tried all the combinations I could think of, and I can’t find any documentation on it.

(I am currently using Node.js v0.11.14.)

Advertisement

Answer

Can I use ES6’s arrow function syntax with generators?

You can’t. Sorry.

According to MDN

The function* statement (function keyword followed by an asterisk) defines a generator function.

From a spec document (my emphasis):

The function syntax is extended to add an optional * token:

FunctionDeclaration: "function" "*"? Identifier "(" FormalParameterList? ")" 
  "{" FunctionBody "}"
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement