The return Statement

Navigation Aids -- This Page           Navigation Aids -- This Topic           Navigation Aids -- This Site

Review of Terms Related to This Topic

Definition and Purpose

The return statement may appear only in the body of a function. Execution of the function stops when the return statement is executed. Program execution returns to the caller. When the optional expression is present, it is evaluated and returned as the value of the function. When the optional expression is omitted from the return statement, the value returned is undefined.

Statement Syntax

return expression;

More on Syntax and Statement Behavior

ECMA-262 Section 12.9

The return statement is an ECMAScript core statement and is detailed is section 12.9 of the ECMAScript Language Specification. Here is a partial extraction of text from this section.

An ECMAScript program is considered syntactically incorrect if it contains a return statement that is not in a function body. A return statement causes a function to cease execution and returns a value to the caller. If expression is omitted, the return value is undefined. Otherwise, the return value is the value of expression.


Rx4AJAX        About Us | Topic Index | Contact Us | Privacy Policy | 2008 This Site Built By PPThompson