please dont rip this site

JavaScript: The Definitive Guide

Previous Chapter 5
Statements
Next
 

5.12 return

As you'll recall, function invocation with the () operator is an expression. All expressions have values, and the return statement is used to specify the value "returned by" a function. This value is the value of the function invocation expression. The syntax of the return statement is:

return [ expression ];

When the return statement is executed, the expression is evaluated, and returned as the value of the function. Execution of the function stops when the return statement is executed, even if there are other statements still remaining in the function body. The return statement can be used to return a value like this:

function square(x) { return x*x; }

The return statement may also be used without an expression to simply terminate execution of the function without returning a value. For example:

function display_object(obj) {
    // first make sure our argument is valid
    // and skip rest of function if it is not.
    if (obj ==index.html null) return;
    // rest of the function goes here...
}

If a function executes a return statement with no expression, or if it never executes a return statement (i.e., it simply executes all the statements in the body and implicitly returns) then the value of the function call expression will be undefined (i.e., the special JavaScript undefined value).

It is a syntax error to use the return statement anywhere except in a function body.


Previous Home Next
function Book Index The Empty Statement

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell

file: /Techref/language/JAVA/SCRIPT/definitive/ch05_12.htm, 5KB, , updated: 2019/10/14 15:00, local time: 2024/11/26 17:18,
TOP NEW HELP FIND: 
3.143.214.226:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/techref/language/JAVA/SCRIPT/definitive/ch05_12.htm"> [Chapter 5] 5.12 return</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .