December 2001
Intermediate to advanced
480 pages
9h 22m
English
The return statement is discussed here instead of in the last chapter because the statement can be used only as part of a function. The role of the return statement is to provide the value of the expressions within the function. But where does the function return the value to? For example, try out the following script:
<html>
<head>
<title>Return</title>
<script language="JavaScript">
function returnMessage() {
var part1="Good ";
var part2="Morning";
var wholeThing=part1 + part2;
return wholeThing;
}
returnMessage();
</script>
</head>
<body bgcolor="mistyrose">
</html> When you run the previous program, nothing appears on your screen other than having a nice, misty, rose-colored screen. The string value “Good Morning” ...
Read now
Unlock full access