First, return control and function results
The syntax is: return expression
Statement End Function executes, returns the calling function, and takes the value of the expression as the result of the function
Second, return control
No function result, the syntax is: return;
In most cases, false is returned for the event handler to prevent the default event behavior. For example, by clicking on a <a> element by default, the page jumps to the page specified by the href attribute of the element.
return false; is equivalent to a terminator,
return true; Just want to be the executor.
In JS, the function of return false is generally used to cancel the default action. For example, if you click a link to trigger a default event other than triggering your onclick event (if you specify it), the jump to the page is performed. So if you want to cancel the object's default action, you can return false.
First in JS, we often return false to prevent the submission of the form or continue to execute the following code , in general, to prevent the execution of the default behavior.
function A () {
if (true)
return false;
}
There's nothing wrong with that.
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, and return false inside a () 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.
Retrun false; Returns the processing result of the error, terminating processing.
Retrun; return control to the page.
Source: http://www.cnblogs.com/weiwang/archive/2013/08/19/3268374.html
JS in return, return true, return false;