Technology Fundamentals

Return Value

Definition

A return value is the value that a function sends back to the part of the code that called it. After the function completes its task, the return value replaces the function call in the code.

Why It Matters

Return values allow functions to produce an output that can be used by other parts of the program, such as being assigned to a variable or passed to another function.

Contextual Example

A function `square(x)` would take a number `x`, calculate `x * x`, and then `return` the result. In your code, you could write `let four = square(2);`, and the variable `four` would hold the return value, 4.

Common Misunderstandings

  • Not all functions have a return value. Some functions perform an action but do not return anything (these are sometimes said to return `void` or `undefined`).
  • The `return` keyword is what specifies the value to be sent back and also immediately stops the execution of the function.

Related Terms

Last Updated: December 17, 2025