14.10 The return Statement
Syntax
A return
statement causes a function to cease execution and, in most cases, returns a value to the caller. If 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
- Return
Completion { [[Type]]:return , [[Value]]:undefined , [[Target]]:empty }.
- Let exprRef be the result of evaluating
Expression . - Let exprValue be ?
GetValue (exprRef). - If !
GetGeneratorKind () isasync , set exprValue to ?Await (exprValue). - Return
Completion { [[Type]]:return , [[Value]]: exprValue, [[Target]]:empty }.