While statementeach time the statement block is executed, it jumps back to check the Boolean value inside the parentheses () and then executes the statement block if True.
while (true) {
Console. log (' true ')
The value of asking for 1+2+3+...+100=?
I=1;
s=0;
while (i<=) {
s=s+i;
I+ + ;
}
Console. log (s);
Continue statementsStop this loop and jump to the top to re-execute
I=1;
while (i<=5) {
if (i= =3) {
Continue
}
Console. log (i);
I+ +;
}
Dead loop
do...while Statementsthe difference from the while statement is that it should be executed first, either way.
I=ten;
do{
Console. log (i);
I+ +;
} while(i<=5)
Console. log (
11
For statementthe order in which the code executes: 1, execute the first statement inside the parentheses 2, the Boolean value that determines the second statement inside the parentheses, if False. Ends the entire for loop and, if true, executes the block of statements inside the curly braces. 3. After each execution of the curly brace statement block, execute the third statement inside the parenthesis. 4. After each execution of the third statement inside the parentheses, jump back to the 2nd step.
For (i=1; I<=; I+ +) {
Console. log (i);
}
1,2,3,4,5,6...20
Array
Arr=[1,2,3,4,5];
Console. log (arr);
Console. log (arr.length);
Console. log (arr[0]);
[1,2,3,4,5]
5
1
0 Basic Learning js--Foundation continued