• SzethFriendOfNimi@lemmy.world
    link
    fedilink
    arrow-up
    129
    ·
    edit-2
    10 个月前

    So in JavaScript there’s the assignment

    =
    

    and the comparator is

    ==
    

    Since there’s no types JS will do implicit conversion before comparison when using == in a case like this

    if(false == '0'){
        //this is true
    }
    

    But with === it doesn’t. It means literally compare these

    if(false === '0'){
        //this is false
    }else{
        //so this will execute instead 
    }
    

    But this, however, will

    var someState = false;
     if(someState === false){
        //this is true
    }