|
|
Q92 How is the "return" reserved word used?
irt.org | Knowledge Base | JavaScript | Misc | Q92 [ previous next ] Q92 How is the "return" reserved word used?Return is used within functions or statements to return a value to the caller of the function. For example you could use a define the following function:
Or, using return as follows:
In this example the document.write would display: The value of the parameter passed is abc It can be used to return true or false:
Another example using is_it_positive:
Obviously these examples are contrived. But the return keyword is extremely useful at returning variable values of data back from a function, depending on the processing carried out in the function. The following function is invalid as it does not always return a value:
Feedback on 'Q92 How is the "return" reserved word used?' |
-- div -->
|