Switch statement multiple cases in JavaScript (Stack Overflow) Multi-case - single operation This method takes advantage of the fact that if there is no break below a case statement it will continue to execute
switch(true){caseisSquare(shape):console.log("该形状是一个正方形。");// 失败,因为正方形也是矩形的一种!caseisRectangle(shape):console.log("该形状是一个矩形。");caseisQuadrilateral(shape):console.log("该形状是一个四边形。");break;caseisCircle(shape):console.log("该形状是一个圆形。");bre...
Switch statement multiple cases in JavaScript (Stack Overflow) Multi-case: single operation This method takes advantage of the fact that if there is no break below acaseclause it will continue to execute the nextcaseclause regardless if thecasemeets the criteria. (See the sectionWhat happens if...