switch(表達式){ case 值1:代碼1;break; case 值2:代碼2;break; case 值3:代碼3;break; case 值4:代碼4;break; ...多個case default:代碼5; }
var jiBie = "E";
switch (jiBie) {
case "A":
console.log("90到100之間");
break;
case "B":
console.log("80到90之間");
break;
case "C":
console.log("70到80之間");
break;
case "D":
console.log("60到70之間");
break;
default :
console.log("0到59之間");
}
var num = "10";//字符串
// console.log("10"===10);//true仍是false
switch (num) {
case 10:
console.log("數字的10");
break;
case "10":
console.log("字符串的10");
break;
}