标签:循环 变量 结构 运算 swap 影响 逻辑 bre reference
貌似很简单的概念,其实还是很值得深挖的。
2.1 变量常量表达式
a3.42.2 算术表达式
a+bi++++i2.3 赋值表达式
a = 3;b = a+42.4 逻辑表达式
a && b1 || 32.5 关系表达式
a < 4b == 52.6 逗号表达式
a=3,b
{ var a = 10; let b = 20; } console.log(a);//10 console.log(b);//ReferenceError
foo: { console.log(‘face‘);//face break foo; console.log(‘this will not be executed‘);//不会输出 }
console.log(‘swap‘);//swap
var i, j; loop1: for (i = 0; i < 3; i++) { //The first for statement is labeled "loop1" loop2: for (j = 0; j < 3; j++) { //The second for statement is labeled "loop2" if (i == 1 && j == 1) { continue ; } /*** i = 0, j = 0 i = 0, j = 1 i = 0, j = 2 i = 1, j = 0 i = 1, j = 2 i = 2, j = 0 i = 2, j = 1 i = 2, j = 2 ***/ console.log("i = " + i + ", j = " + j); } } var i, j; loop1: for (i = 0; i < 3; i++) { //The first for statement is labeled "loop1" loop2: for (j = 0; j < 3; j++) { //The second for statement is labeled "loop2" if (i == 1 && j == 1) { continue loop1; } /*** i = 0, j = 0 i = 0, j = 1 i = 0, j = 2 i = 1, j = 0 i = 2, j = 0 i = 2, j = 1 i = 2, j = 2 ***/ console.log("i = " + i + ", j = " + j); } }
pmx:{ var a = 10; console.log(a); } { console.log("hello"); break pmx; console.log("hi"); }
while(true){ console.log("while 语句"); break; } do{ console.log(‘do while语句‘) break; }while(true); for(;;){ console.log("for 语句"); break; }
var a = 10; if(a < 30){ console.log("if 语句") } if(a < 20){ console.log("if else语句"); }else{ } if(a < 5){ }else if(a < 6){ }else if(a < 11){ console.log("if else if else if 。。。语句"); } switch(a){ case 1: break; case 2: break; case 10: console.log("switch 语句"); break; default: }
标签:循环 变量 结构 运算 swap 影响 逻辑 bre reference
原文地址:http://www.cnblogs.com/bibiafa/p/7833929.html