虽然在当前ES6 draft中找到了Symbol.iterator
,但我是否可以将Symbol.iterator
作为类的生成方法的有效性阐明如下(对草案的任何引用都是有用):
class C {
*[Symbol.iterator]() {
...
}
}
答案 0 :(得分:1)
我通常不会看一下规范草案,但是在这个场合:
ClassDeclaration https://people.mozilla.org/~jorendorff/es6-draft.html#sec-class-definitions
ClassElement
MethodDefinition https://people.mozilla.org/~jorendorff/es6-draft.html#sec-method-definitions
GeneratorMethod https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generator-function-definitions
* PropertyName
PropertyName https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-initializer
ComputedPropertyName
[AssignmentExpression]