14.10 The return Statement


ReturnStatement[Yield, Await] : return ; return [no LineTerminator here] Expression[+In, ?Yield, ?Await] ; Note

A return statement causes a function to cease execution and, in most cases, returns a value to the caller. If Expression is omitted, the return value is undefined. Otherwise, the return value is the value of Expression. A return statement may not actually return a value to the caller depending on surrounding context. For example, in a try block, a return statement's completion record may be replaced with another completion record during evaluation of the finally block.

14.10.1 Runtime Semantics: Evaluation

ReturnStatement : return ;
  1. Return Completion { [[Type]]: return, [[Value]]: undefined, [[Target]]: empty }.
ReturnStatement : return Expression ;
  1. Let exprRef be the result of evaluating Expression.
  2. Let exprValue be ? GetValue(exprRef).
  3. If ! GetGeneratorKind() is async, set exprValue to ? Await(exprValue).
  4. Return Completion { [[Type]]: return, [[Value]]: exprValue, [[Target]]: empty }.