Is it bad practice to pass a string to settimeout? If yes, why? [duplicate]
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.