Use an anonymous function, for example:
setTimeout(function() { fnName('arg'); }, time);
In general, never pass a string to setTimeout()or setInterval(), if you can avoid it, there are other side effects besides bad practice ... for example. the area you are in when it works.
As a note, if you don't need an argument, simply:
setTimeout(fnName, time);
source
share