Skip to content

JS Return Statement

Syntax

The return statement in JavaScript exits a function and optionally specifies a value to be returned to the function caller.

function functionName() {
return value;
}
// Call function
functionName();

Example

function getGreeting() {
return 'Hello World';
}
let greeting = getGreeting();
console.log(greeting); // Output: Hello World