First, return control and function results
Syntax: return expression;
Executes at the end of a function statement and returns the value of the expression as the result of the function;
Second, return control
Returns the null value, syntax: return;
In general, return Return:false for the event handler function; , the function is to block the default event behavior and cancel the default action, for example, by clicking on a <a> element by default, the page jumps to the page specified by the element href attribute, and when you use return false, it is equivalent to a terminator and return true; Equivalent to an executor.
For example: <a href= "eoh.html" onclick= "return Add_onclick ()" >open</a>//return false/true
<script>
function Add_onclick () {
return false; False to prevent jumps
}
</script>
In JS, return false is often used; To prevent the form from committing or to continue executing the following code, which is the default behavior that prevents execution.
For example: function sum () {
if (true) {
return false;
}
}
function Test () {
SUM ();
Num ();
}
Although the SUM function returns false to block commits, but does not affect the execution of the NUM function, returning false in a function is only equivalent to a return value for the test () function, and does not affect the execution of the test () function, in short, return:false; only valid for the current function. Does not affect other function executions.
The use of return in JS