What's the differenct between passing a function and the function call itself in javascript?
Posted
by Mingus Rude
on Stack Overflow
See other posts from Stack Overflow
or by Mingus Rude
Published on 2010-05-31T14:39:16Z
Indexed on
2010/05/31
14:43 UTC
Read the original article
Hit count: 178
JavaScript
In the application I'm building I'm polling for a status update and I have noticed that if the call is made as follows the timeout fires continuously:
setTimeout($.get("http://localhost:8080/status", function(data) { UpdateStatus(data);}), 1000);
While if use a function instead the timeout fires every 1000 ms:
setTimeout(function() {$.get("http://localhost:8080/status", function(data) { UpdateStatus(data);})}, 1000);
Why?
© Stack Overflow or respective owner