setTimeout func|code delay For example, the code below calls alert('hi') after one second: function f() { alert('Hi') } setTimeout(f, 1000) If the first argument is a string, the interpreter creates an anonymous function at place from it. So, this call works the same. setTimeout("alert('Hi')", 1000) Using a string version is not recommended, it causes problems with minificators. It’s here mainly for compatibility with older JavaScript code. Use anonymous functions instead:
Read full article from Understanding timers: setTimeout and setInterval | JavaScript Tutorial
No comments:
Post a Comment