Why doesn't the following work in Firefox (v16)?
var t = setTimeout(foo(), 1000);
The error I get in the console is: "useless setTimeout call (missing quotes around argument?)". Wrapping it in quotes doesn't seem to do much, except making it render as a string (unsurprisingly).
It does however work fine when I wrap it in an anonymous function like so:
var t =
setTimeout(function(){
foo();
}, 1000);
But why is it necessary? Why doesn't it explode in Webkit or Opera? Stroke of luck?
Its because you are invoking foo in your first example.
Its basically the same as doing this:
var tempResultOfFoo = foo();
var t = setTimeout(tempResultOfFoo, 1000);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With