Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The return statement ends function execution and specifies a value to be returned to the function caller.
The expression whose value is to be returned. If omitted, undefined is returned.
The return statement can only be used within function bodies. When a return statement is used in a function body, the execution of the function is stopped. The return statement has different effects when placed in different functions:
If a return statement is executed within a try block, its finally block, if present, is first executed, before the value is actually returned.
The syntax forbids line terminators between the return keyword and the expression to be returned.
The code above is transformed by automatic semicolon insertion (ASI) into:
This makes the function return undefined and the a + b expression is never evaluated. This may generate a warning in the console.
To avoid this problem (to prevent ASI), you could use parentheses:
A function immediately stops at the point where return is called.
See also the article about Closures.
| ECMAScript® 2027 Language Specification # sec-return-statement |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 8, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.