Use the fall-through feature of the switch
statement.(使用switch
语句的直通功能。)
A matched case will run until a break
(or the end of the switch
statement) is found, so you could write it like:(匹配的大小写将一直运行到找到break
(或switch
语句的末尾)为止,因此您可以这样写:)
switch (varName)
{
case "afshin":
case "saeed":
case "larry":
alert('Hey');
break;
default:
alert('Default case');
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…