JS中的switch用法

记录一下这种用法,可在case语句后做简单的判断操作

   switch(true) {
          case item.TOEICSCORE < 250:
              countless250++;
            break;
          case item.TOEICSCORE >= 250 && item.TOEICSCORE < 350:
              count250To350++;
            break;
          case item.TOEICSCORE >= 350 && item.TOEICSCORE < 450:
              count350To450++;
            break;
          case item.TOEICSCORE >= 450 && item.TOEICSCORE < 550:
              count450To550++;
            break;
          case item.TOEICSCORE >= 550 && item.TOEICSCORE < 650:
              count550To650++;
            break;
          case item.TOEICSCORE >= 650:
              countThan650++;
            break;
        }

你可能感兴趣的:(ECMAScript,6)