0 Basic Learning js--Foundation continued

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.