lundi 30 août 2021

Why does just assigning setTimeout to a variable simply executes the argument function, inside if statement in javascript? [duplicate]

I have a simple if statement with 'true' as condition now my code isI assigned a variable a the value of setTimeout but i dont want to execute it but javascript still executes it, Why?

if(true){
        var a = setTimeout(alert("hello world"), 3000);
    }

Aucun commentaire:

Enregistrer un commentaire