JavaScript return Statement
The return statement ends a function and sends a value back to the code that called it.
Description
The return statement ends the execution of a function and specifies the value to give back to the caller. A function without a return, or with an empty one, returns undefined. Returning early is a good way to handle special cases before the main logic.
Beware of automatic semicolon insertion: a line break straight after return ends the statement, so return followed by a value on the next line returns undefined. Keep the value on the same line, or start a parenthesis there.
A function can contain several return statements, but only one runs per call. Inside a try block with a finally clause, the finally code still runs before the function actually returns. In an async function, the returned value becomes the fulfilled value of the promise, and in an arrow function with an expression body the result is returned without needing the keyword at all.
Syntax
return;
return expression;Example
Browser Support
The following information will show you the current browser support for the return statement. Hover over a browser icon to see the version that first introduced support for this statement.
Desktop





Tablets & Mobile





