Difference between arguments in setInterval calls
Posted
by
Martin Janiczek
on Stack Overflow
See other posts from Stack Overflow
or by Martin Janiczek
Published on 2011-01-18T01:43:05Z
Indexed on
2011/01/18
1:53 UTC
Read the original article
Hit count: 299
What's the difference between these setInterval calls and which ones should be used?
setInterval("myFunction()",1000)
setInterval("myFunction",1000)
setInterval(myFunction(),1000)
setInterval(myFunction,1000)
My guess is that JS uses eval() on the first two (strings) and calls the latter two directly.
Also, I don't understand the difference between the calls with and without parentheses. The ones with parentheses call it directly and then periodically call its return value?
© Stack Overflow or respective owner