function add(a, b) {
return a + b
}
위 함수를 AST explorer(https://astexplorer.net/) 에서 분석하면, 다음의 구조를 가져올 수 있다.
{
type: "FunctionDeclaration"
id: {
type: "Identifier"
name: "add"
},
params: [
{
type: "Identifier"
name: "a"
},
{
type: "Identifier"
name: "b"
},
],
body: {
type: "BlockStatement"
body: [
{
type: "ReturnStatement"
argument: {
type: "BinaryExpression"
left: {
type: "Identifier"
name: "a"
}
operator: "+"
right: {
type: "Identifier"
name: "b"
}
}
}
]
}
}