0

I'm working with the Esprima parser, it outputs an AST format which is compatible with the Mozilla Spider Monkey Parser API.

In the Mozilla Docs, it specifies the Function node as:

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

What will the defaults property contain? It always appears as just an empty array.

Drahcir
  • 11,772
  • 24
  • 86
  • 128

1 Answers1

0

defaults of Mozilla JS AST contains ES6 default parameter values.

For example,

    function t(i = 20) { }

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

Because it is based on ES6 draft, Esprima master branch doesn't recognize it.

swiftBoy
  • 35,607
  • 26
  • 136
  • 135