Favorites

JavaScript return Statement

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
return
JavaScript Control FlowThis statement is supported by all modern browsers.
Updated 28th November 2026

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

function grade(score) {
  if (score < 0 || score > 100) return 'invalid';
  if (score >= 50) return 'pass';
  return 'fail';
}
console.log(grade(72), grade(30), grade(120));

function broken() {
  return
    'never returned';
}
console.log(broken());

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.

This statement is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee