return value Last updated: 17. Oct 2026

Keyword

Ends the current function and returns a value to the caller. A bare return; returns undefined.

Parameters

Name Type Description
value any

Value to return

Returns

Exits the function and returns the value. In a #/API file, the value returned from the exported function is sent to the client as JSON.

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
function add(a, b) {
    return a + b; // Exits the function and returns the sum
}

write(add(2, 3)); // Outputs 5

Output

The JS code above produces the output shown below:
5