我可以在生成器中使用 ES6 的箭头函数语法吗?(箭头符号) [英] Can I use ES6's arrow function syntax with generators? (arrow notation)
问题描述
也就是我怎么表达
function *(next) {}
使用箭头语法?我尝试了所有我能想到的组合,但找不到任何相关文档.
(我目前使用的是 Node.js v0.11.14.)
我可以在生成器中使用 ES6 的箭头函数语法吗?
你不能.对不起.
根据 MDN><块引用>
function*
语句(function
关键字后跟一个星号)定义了一个生成器函数.
来自规范文档(我的重点):
<块引用>function 语法被扩展为添加一个可选的 *
标记:
FunctionDeclaration:函数"*"?标识符 "(" FormalParameterList? ")""{" 函数体 "}"
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.)
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 "}"
这篇关于我可以在生成器中使用 ES6 的箭头函数语法吗?(箭头符号)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!