15.3 Arrow Function Definitions


ArrowFunction[In, Yield, Await] : ArrowParameters[?Yield, ?Await] [no LineTerminator here] => ConciseBody[?In] ArrowParameters[Yield, Await] : BindingIdentifier[?Yield, ?Await] CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] ConciseBody[In] : [lookahead ≠ {] ExpressionBody[?In, ~Await] { FunctionBody[~Yield, ~Await] } ExpressionBody[In, Await] : AssignmentExpression[?In, ~Yield, ?Await]

Supplemental Syntax

When processing an instance of the production
ArrowParameters[Yield, Await] : CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
the interpretation of CoverParenthesizedExpressionAndArrowParameterList is refined using the following grammar:

ArrowFormalParameters[Yield, Await] : ( UniqueFormalParameters[?Yield, ?Await] )

15.3.1 Static Semantics: Early Errors

ArrowFunction : ArrowParameters => ConciseBody ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList

15.3.2 Static Semantics: ConciseBodyContainsUseStrict

ConciseBody : ExpressionBody
  1. Return false.
ConciseBody : { FunctionBody }
  1. Return FunctionBodyContainsUseStrict of FunctionBody.

15.3.3 Static Semantics: CoveredFormalsList

ArrowParameters : BindingIdentifier
  1. Return this ArrowParameters.
CoverParenthesizedExpressionAndArrowParameterList : ( Expression ) ( Expression , ) ( ) ( ... BindingIdentifier ) ( ... BindingPattern ) ( Expression , ... BindingIdentifier ) ( Expression , ... BindingPattern )
  1. Return the ArrowFormalParameters that is covered by CoverParenthesizedExpressionAndArrowParameterList.

15.3.4 Runtime Semantics: EvaluateConciseBody

With parameters functionObject and argumentsList (a List).

ConciseBody : ExpressionBody
  1. Perform ? FunctionDeclarationInstantiation(functionObject, argumentsList).
  2. Return the result of evaluating ExpressionBody.

15.3.5 Runtime Semantics: InstantiateArrowFunctionExpression

With optional parameter name.

ArrowFunction : ArrowParameters => ConciseBody
  1. If name is not present, set name to "".
  2. Let scope be the LexicalEnvironment of the running execution context.
  3. Let sourceText be the source text matched by ArrowFunction.
  4. Let parameters be CoveredFormalsList of ArrowParameters.
  5. Let closure be OrdinaryFunctionCreate(%Function.prototype%, sourceText, parameters, ConciseBody, lexical-this, scope).
  6. Perform SetFunctionName(closure, name).
  7. Return closure.

An ArrowFunction does not define local bindings for arguments, super, this, or new.target. Any reference to arguments, super, this, or new.target within an ArrowFunction must resolve to a binding in a lexically enclosing environment. Typically this will be the Function Environment of an immediately enclosing function. Even though an ArrowFunction may contain references to super, the function object created in step 5 is not made into a method by performing MakeMethod. An ArrowFunction that references super is always contained within a non-ArrowFunction and the necessary state to implement super is accessible via the scope that is captured by the function object of the ArrowFunction.

15.3.6 Runtime Semantics: Evaluation

ArrowFunction : ArrowParameters => ConciseBody
  1. Return InstantiateArrowFunctionExpression of ArrowFunction.
ExpressionBody : AssignmentExpression
  1. Let exprRef be the result of evaluating AssignmentExpression.
  2. Let exprValue be ? GetValue(exprRef).
  3. Return Completion { [[Type]]: return, [[Value]]: exprValue, [[Target]]: empty }.