First, return control and function results,
The syntax is: return expression, statement End Function execution, return call function, and the value of the expression as the result of the function
Second, return control,
No function result, the syntax is: return;
You can return FALSE if you want to cancel the object's default action.
First in JS, we often use return false to prevent the submission of the form or the person continues to execute the following code, in general, to prevent the execution of the default behavior.
function A () {
if (True)
return false;
}, there is no problem with this.
If I change into this
function Test () {
A ();
b ();
C ();
}
Even if the a function returns false to prevent the commit, it does not affect the execution of the B () and C () functions. Call the A () function in the test () function.
Return false is equivalent to the return value for the test () function. The test () function cannot be prevented from executing.
In summary: Return false is valid only in the current function and does not affect the execution of other external functions.
Three: summary
Retrun true; Returns the correct processing result.
return false; Branch error processing result, terminate processing.
return; Returns control to the page.
JS in return, return true, return false;