views:

107

answers:

1

The HTML5 specifications states that setTimeout can be run without the additional "timeout" argument which is supposed to say after how many milliseconds will the function "handler" be scheduled.

handle = window . setTimeout( handler [, timeout [, arguments ] ] )
   Schedules a timeout to run handler after timeout milliseconds. Any arguments are passed straight through to the handler.

However, I failed to find anywhere which explains what happens when no "timeout" time period is set.

An example usage is, the animation implementation int the Raphael library.

animationElements[length] && win.setTimeout(animation);
+3  A: 

See http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#get-the-timeout

  1. Let timeout be the second argument to the method, or zero if the argument was omitted.
Adam Wright
Beat me to it :-) +1. I was going to add to my own answer (but may as well add it here) that just because the timeout argument is 0 doesn't necessarily mean it will run instantly, it will still be queued to run when the thread becomes idle, e.g. after all current code execution is finished.
Andy E
Grr... don't know how I missed that. Sorry and thanks.
Elazar Leibovich