samedi 27 mars 2021

promise and setTimeout() [duplicate]

I want to know why in below code we set function() { myFunction("I love You !!!"); } for the first parameter not myFunction("I love you !!!")? I tested it but it seems when we set the second one it send it immediately and doesn't wait for 3000ms. but I don't know why.

setTimeout(function() { myFunction("I love You !!!"); }, 3000);

function myFunction(value) {
    document.getElementById("demo").innerHTML = value;
}



Aucun commentaire:

Enregistrer un commentaire