Javascript multiple or condition check

前端 未结 4 1688
暗喜
暗喜 2021-01-29 06:44

I have struck with some simple if else checking

var IsCompanyContacttitleUpdate = false;
var ContactStatus = -1;

if ((IsCompanyContacttitleUpdate == false) &am         


        
4条回答
  •  孤独总比滥情好
    2021-01-29 07:35

    This ContactStatus == 2 || 3 || 4 is invalid (maybe invalid is not the correct word, to be more accurate let's say that it's not doing what you think it does)

    For your scenario you'll need to use

    ContactStatus == 2 || ContactStatus == 3 || ContactStatus == 4
    

    Your code could be tranlated to

    ContactStatus == 2 || true || true
    

    And this is always true.

提交回复
热议问题