javascript--Syntax 2--statement structure

Source: Internet
Author: User

javascript--Grammar 21, experience

When judging, keep the left side constant.
Switch in Java only supports four types, JavaScript is a weak type, and all are supported.

Display method:

x=//                alert ("+x");/                 /write data directly to the current page.                 document.write ("x=" +x+ "<br/>");
Second, the Code
1<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" >234<meta http-equiv= "Content-type" content= "text/html; CHARSET=GBK ">5<title>untitled document</title>67<body>8<script type= "Text/javascript" >9             /*Ten * Statement: One * 1, sequential structure.  A              *      - * 2, judging the structure.  - * Representative statement: If. the * 3, select structure.  - * Switch - * 4, loop structure.  - * while do and for + * 5, other statements.  - * Break: Jump out of the selection and jump out of the loop.  + * Continue: Used for looping statements, ending this cycle to continue the next cycle.  A              */ at              - //alert ("ABC1"); - //alert ("ABC2"); -          -          - //            ------------------------------------------------ in             /* - var x = 3; to //if (x=4) {//note.  + if (4==x) {//suggest to leave the constant on the left. Fix the code with an error.  - alert ("yes"); the }else{ * alert ("no"); $             }Panax Notoginseng              -              the              + if (x>1) A alert ("a"); the else if (x>2) + alert ("B"); - else if (x>3) $ alert ("C"); $ Else - alert ("D"); -                  the             */     -         Wuyi //            ------------------------------------------------ the             /* - //select structure.  Wu var x = "abc"; - switch (x) { About                  $ Case "KK": - alert ("a"); - Break ; - Case "ABC": A alert ("B"); + Break ; the Default: - alert ("C"); $ break;//omitted. Because it's the last statement, and the curly braces are behind it. the             } the             */ the              the              -              in             //loop structure.  the             /* the var x = 1; About document.write ("<font color= ' Blue ' >");//color control, HTML content the While (X<10) the             { the //Alert ("x=" +x); + //write the data directly to the current page. document.write ("x=" +x+ "<br/>"); the x + +;Bayi             } the document.write ("</font>"); the              -              - For (var x=0; x<3; x + +) { the document.write ("x=" +x); the             } the             */ the              -              the             /* the  W:for (var x=0; x<3; x + +) {//label the For (var y=0; y<4; y++) {94 document.write ("x===" +x); the continue W; Jumps out of the current loop.  the                 } the             }98             */ About              -             101</script>102         103         104          the         106</body>107

javascript--Syntax 2--statement structure

Related Article

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.