0

私はEsprimaパーサーを使用しています。Mozilla Spider Monkey Parser APIと互換性のあるAST形式を出力します。

Mozilla Docsでは、Functionノードを次のように指定しています。

interface Function <: Node {
    id: Identifier | null;
    params: [ Pattern ];
    defaults: [ Expression ];
    rest: Identifier | null;
    body: BlockStatement | Expression;
    generator: boolean;
    expression: boolean;
}

defaultsプロパティには何が含まれますか? 常に空の配列として表示されます。

4

1 に答える 1

0

デフォルトの Mozilla JS AST には、ES6 のデフォルト パラメータ値が含まれています。

例えば、

    function t(i = 20) { }

defaults will be [{ type: 'Literal', value: 20 }].

ES6 のドラフトに基づいているため、Esprima の master ブランチでは認識されません。

于 2013-03-13T05:44:27.910 に答える