JavaScript syntax: operator conditional statement If...else ... Conditional statement Switch Loop statement for Loop statement while jump statement
JS operator
1, arithmetic operators: +-*%/+ +--(i++ first operation in addition ++i first add again operation)
2. Assignment operator: = + = = *=%=/= (i+=j = = i=i+j)
3, the string operation (i= "," j= "18"; i+j=1218) (i=12;j= "; i+j=1218") (i= "12" +18; document.write (i) 1218)
4, comparison operator: = = (value) = = = (value and type)! = = = < > <= >= (return bool type)
5. Logical operator:&& | | ! (and/or non)(returns BOOL type) ! (I==J) Take counter
6, the condition operator: a<b?a:b a=12; b=18; document.write (a<b? ") A less than B ":" A>b ");
JS Conditional statement
1.if...else ...
2.Switch
JS Loop statement
1. For Loop for/in
<script>
var i=[1,3,5,7,9];
for (var j = 0; J < 6; J + +) {//for (three conditions can be taken out two, two semicolons cannot go)
document.write (i[j]+ "<br>");
};
var a=[2,4,6,8,10];
var b;
for (b in a) {
document.write (a[b]+ "<br/>");
};
</script>
2. While-do ... while (when first judgment, in execution. Do...while first execution, in judgment)
var m=1;
while (M<10) {
document.write ("m=" +m+ "<br/>");
m++;
};
var n=1;
do{
document.write ("m=" +m+ "<br/>");
m++;
}
while (N<10) {
};
3. JS Jump statement
1. Break (terminate this cycle)
2, continue (jump out of this cycle, continue the next cycle)
JavaScript syntax explanation