究竟是-1、0和1值的含义吗?

时间:2019-06-20 12:13:26

标签: if-statement key-value comparison-operators

在代码片段的if else语句中,值<0和-1的含义是什么。我知道它做什么,但是不明白为什么?

var partyButton = document.getElementById("partyTimeButton");

var partyEvent = function(){

    if( partyTime < 0 ){

    partyTime = new Date().getHours();             
    partyButton.innerText = "Party Over!";
    partyButton.style.backgroundColor = "#0A8DAB";

}else if( partyTime = -1 ){                        

    partyButton.innerText = "Party Time!";
    partyButton.style.backgroundColor = "#222";

   }
}

partyButton.addEventListener('click', partyEvent);
partyEvent();

0 个答案:

没有答案