javascript - How can I delay a function with parameter? -


this question has answer here:

i trying make game, machine takes while respond, user knows machine 'deciding' move. need use settimeout() method, want specify parameter function.

example: settimeout(myfunction('p'), 1000);. problem when specify parameter, function runs fine, there´s no delay.

when write settimeout(myfunction('p'), 1000);, myfunction('p') evaluated , settimeout(returnvalueofmyfunction, 1000) evaluated.

this code run anonymous function @ correct time:

settimeout(function (){myfunction('p')}, 1000); 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo