mercredi 27 janvier 2021

In Javascript, when using an if statement to compare zero and not false with triple equal signs, why is not false equal to false?

I'm creating a typing test in Javascript. When the user presses the keyboard button, the typing test begins if zero keys have been pressed previously. If textEnteredLength (keys pressed) is === 0 and !timerRunning is equal to not false. Why does this function run? 0 === not false, is not a true statement, right?

    var timerRunning = false;
    
    function start() {
    let textEnterdLength = testArea.value.length;
    if (textEnterdLength === 0 && !timerRunning){
        timerRunning = true;
        interval = setInterval(runTimer, 10);
    }

Aucun commentaire:

Enregistrer un commentaire