JavaScript return statement
JavaScript Statements Reference Manual
Examples
Returns the value of PI:
return Math.PI;
}
Output:
try it"
Bottom of this article contains more examples.
Definition and Usage
return statement terminates execution of the function and the function's return value.
Please read our JavaScript tutorials to learn more about the function of the content. First, we can first understand JavaScript function and JavaScript scope . You can view more detailed data about the function definition , parameters , call and closures .
Browser Support
Statements | |||||
---|---|---|---|---|---|
return | Yes | Yes | Yes | Yes | Yes |
grammar
Parameter Value
parameter | description |
---|---|
value | Optional. Returns only the specified function. If omitted, returns undefined |
technical details
JavaScript version: | 1.0 |
---|
More examples
Examples
Calculate the product of two numbers and returns the result:
function myFunction (a, b) {
return a * b; // function returns the product of a and b
}
try it"
Related Pages
JavaScript Tutorials: JavaScript function
JavaScript Tutorials: JavaScript Scope
JavaScript Tutorials: JavaScript function definition
JavaScript Tutorials: JavaScript function parameters
JavaScript Tutorials: JavaScript function call
JavaScript Tutorials: JavaScript function closures
JavaScript Reference Manual: JavaScript function statements
JavaScript Statements Reference Manual