Skip navigation

Tag Archives: timeout

You might be knowing how to call setTimeout javascript function. It is simple
setTimeout(myFunction, myTimeoutInMilliSeconds);

But if you want to pass a parameter with myFunction
setTimeout(myFunction(para), myTimeoutInMilliSeconds); // won't work

The javascript closure comes as a great rescue.
setTimeout(function(){myFunction(para)}, myTimeoutInMilliSeconds);

This is best example of using closure.