Possible Duplicate:
Is there ever a good reason to pass a string to setTimeout?
I just read a comment stating it is bad practice.. Is that so? And why?
Possible Duplicate:
Is there ever a good reason to pass a string to setTimeout?
I just read a comment stating it is bad practice.. Is that so? And why?
Yes, it is.
The string must be eval
'd, which is evil (and very slow).
It also prevents you from using local variables in the callback.
It's a bad practice for the same reason that using eval
is bad. You're executing strings as code. This has both performance and security penalties.