Return Values
Returning data from functions.
Examples
Basic Return
Returning the product of two numbers.
function myFunction(a, b) {
return a * b;
}
let x = myFunction(4, 3); // x will be 12Return Ends Execution
Code after the return statement is unreachable.
function test() {
return true;
console.log("This will never be printed");
}
test();Test Your Knowledge
JavaScript Quiz
No quiz available for this topic yet.