Author: Tales from the Evil Empire : ASP.NET | Posted on: 5/14/2009 10:04:36 PM | Views : 800

JavaScript has two ways of delaying execution of code: setInterval and setTimeout . Both take a function or a string as the first parameter, and a number of milliseconds as the second parameter. The only difference is that the code provided to setInterval will run every n milliseconds whereas the code in setTimeout will run only once. Before I explain why I think setInterval is evil, allow me to rant on a related subject for a paragraph: you should never pass a string into any of those functions and instead always pass a function reference (unless you really, really know what you?re doing). If you pass a string, it will have to be evaluated on the fly, and eval is quite evil itself (unless you really, really know what you?re doing). It might...(read more) ...

Go to the complete details ...