Statements

return statement

Try the free JavaScript compiler

Ends the current function evaluation with a return completion. Without an expression the returned value is undefined. A line break immediately after return can result in automatic semicolon insertion; keep the returned expression on the same line or begin a grouped expression there.

Formal Syntax & Structure

javascript syntaxjavascript
return expression;

Working Example

Example Snippetjavascript
function answer() { return 42; }console.log(answer());
JavaScript Reference