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.
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.