July 1998
Intermediate to advanced
1456 pages
65h 5m
English
return — NN 2 IE J1 ECMA 1
Stops execution of the current function. A return
statement can be located anywhere within the function, including
inside control structures. You can optionally specify a value to be
returned to the calling statement. This return value can be any
JavaScript data type. If a return statement that
returns a value is in a loop or other control structure, there must
be a return statement for each branch of the
execution tree, including a default return
statement if execution should reach the main execution scope near or
at the end of the function.
return [value]function validateNumber(form) {
var oneChar
for (var i = 0; i < userEntry.length; i++) {
oneChar = form.entry.value.charAt(i)
if (oneChar < "0" || oneChar > "9") {
return false
}
}
return true
}Read now
Unlock full access