1, can end the whole cycle
The function fun () {
Alert (" function to perform the ");
For (var I=1; I & lt; 5; I++) {
If (I==2) {
//break//exit loop
//continue//jump out of the loop
The return//to end the entire function
}
The console. The log (I);
}
Alert (" function performs over ");
}
Fun ();
2, behind the return statement will not be executed
The function fun2 () {
Alert (123);
return 1;
Alert (456);//this function does not perform, placed behind the return
}
Fun2 ();
3, can be used as a return value return
The function fun3 () {
The function fun4 () {
Return 1;
//fun4 as return values return
Return fun4;
}
The console. The log (fun3 () ());
CodePudding user response: