It is maybe incredibly easy but I couldn’t solve what was going on.
function doSomething(a)
{
var num=10;
return setTimeout(
function(){ a(num); }, 1000);
}
The only thing that actually confuses me is the a(num) part. What actually it does?
Reminder: I really am asking because I’m not familiar with the javascript syntax.
When the
functiondoSomething()is executed it is passed the parametera,ais also somefunctionthat is then called whensetTimeout()expires after 1 second,then calling the
functiona()passing the argument callednumExample usage: