* * logic Control as the core of JS programming, in the coding is most commonly used, then in the process of using some common problems need to use a specific statement to achieve.
We use more is the circular statement, in the circular statement, there must be meet the conditions or do not meet the conditions to jump out of the cycle of the moment, this time to use the circular concluding sentence, is usually used to break out of the current whole cycle; If you jump out of a loop and continue when you meet the At this point, the available Continue;return function is generally used to end the function. break means to jump out of the entire loop, which is the end. Most commonly used in switch control statements, as follows:
Switch (property) {case
1:
function () {};
break;
Case 2:
function () {};
break;
...
...
...
Default:
function () {};
}
The loop statement represents the value of the judgement property, satisfies any kind of case, executes the corresponding function, and then exits the fragment. continue means to jump out of this loop and generally use it in a for loop. As follows:
for (int i=0;i<5;i++) {
if (i==2)
continue;
var a=i;
Console.log (a);
}
This function, when i=2, does not execute the following output statement, but continues executing the output statement when i!=2. If continue is replaced with a break, the output statement is not executed after 2 and 2. Return is generally used in functions to block the execution and termination functions of the default function. You can use return False if you block bubbling; To achieve. The End function is shown as follows:
Function Show () {
var a=2;
return A;
var b=0;
return b;
}
The execution of this code results in 2. In other words, when execution to return a; , the show function ends, does not execute the following statements, and does not overwrite the returned value.