ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

Javascript 利用 switch 语句进行范围判断

2021-07-09 15:07:40  阅读:517  来源: 互联网

标签:语句 case none Javascript alert break switch between


const x = 6;
switch (true) {
    case (x < 5):
        alert("less than five");
        break;
    case (x < 9):
        alert("between 5 and 8");
        break;
    case (x < 12):
        alert("between 9 and 11");
        break;
    default:
        alert("none");
        break;
}

标签:语句,case,none,Javascript,alert,break,switch,between
来源: https://blog.51cto.com/u_15297912/3027807

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有