The return statement represents the need to return a value, and you do not need to use the return statement if you do not need it. are similar to an exit, return can end the execution of part of the code in the body of the method after return. return False or return true is commonly used to determine some results.
Return:1. Return control with function result that is return + expression, call function, and return the value of the expression
2. Return control, no function value or return. Is the function does not need to return the value, when you need to abort the function down, use this
In most cases, the function undergoes a series of operations, and there is a return value, which is returned to the external need, which is usually returned, that is, return is the returning value, not the terminating function. But note: return expression; The code after this function is no longer running.
For example: function onclick () {
/* **/in arithmetic
return expression;
/* Other code */==>> not executed
}
Return false.:1. Usually let the function return false is to prevent the default default event from occurring (that is, continue executing the following code) when a certain condition is not met or met, but note that return false is valid only in the current function and does not affect the execution of other external functions.
2. Return Error processing results
3. Termination of processing.
4. Block the submission form (onsubmit= "return false";).
For example:
<ul id= "Imglib" >
<li><a href= "Img/1.png" title= "Santa 1" onclick= "showpic (this); return false" > Santa Claus </a></li>
<li><a href= "img/3.png" title= "singular Tower 1" onclick= "showpic (this); return false" > singular tower </a></li>
<li><a href= "Img/4.png" title= "Robot 1" onclick= "showpic (this); return false" > Robot </a></li>
</ul>
Clicking the hyperlink <a>, does not open the page that jumps to the href, but just runs the show () function. That prevents the default event from occurring.
Return true: Returns the normal result of the processing, if this is used to return the following code to terminate.
JS in return, return false, return true what each means