if语句中是否有“或”条件的简写,我觉得重复是愚蠢的,在下面的情况下,“a”变量重复检查所有“或”条件:
if(a != 'Cancelled' || a != 'Rejected' || a != 'Delivered' || a != 'Confirmed'){
//execute something here
}
最佳答案
if (['Cancelled', 'Rejected', 'Delivered', 'Confirmed'].indexOf(a) == -1) {
// do stuff here
}
关于JavaScript - if 语句中 "Or"的简写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39520239/