Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
500 views
in Technique[技术] by (71.8m points)

javascript - 我可以在生成器中使用ES6的arrow函数语法吗? (箭头符号)(Can I use ES6's arrow function syntax with generators? (arrow notation))

ie how do I express this:

(即我如何表达这一点:)

function *(next) {}

with arrows.

(与箭头。)

I've tried all the combinations I could think of, and I can't find any documentation on it.

(我尝试了所有我能想到的组合,但找不到任何文档。)

(currently using node v0.11.14)

((当前使用节点v0.11.14))

  ask by Ashley Coolman translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

(我可以在生成器中使用ES6的arrow函数语法吗?)

You can't.

(你不能)

Sorry.

(抱歉。)

According to MDN

(根据MDN)

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

(function*语句( function关键字后跟一个星号)定义了生成器函数。)

From a spec document (my emphasis):

(从规格文件中 (我的重点):)

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

(扩展了函数语法,以添加可选的*标记:)

FunctionDeclaration: "function" "*"? Identifier "(" FormalParameterList? ")" 
  "{" FunctionBody "}"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...