W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2011

[whatwg] 7.3 Timers

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Mon, 28 Feb 2011 14:19:17 -0500
Message-ID: <4D6BF535.3050000@mit.edu>
On 2/28/11 2:13 PM, Alexandre Morgaut wrote:
> When I read: Any arguments are passed straight through to the handler.
> I wonder if it does not mean that I should pass one parameter per argument to pass to the handler
> ->  setTimeout( myhandler, 1000, arg1, arg2, arg3);


> But well, the signature looks like there is only one parameter

No.  If there were only one parameter, the signature would say |in any 
args|.  It actually says |in any... args| which means any number of 
arguments.  See http://www.w3.org/TR/WebIDL/#dfn-variadic-operation

> But couldn't setTimeout() accept natively a Date object in place of the timeout parameter

Note that if you set a timeout for 1 hour from now, and then the 
computer goes to sleep for 3 hours, then the timeout will fire 1 hour 
after the computer wakes up, not immediately on wakeup.

So if you're depending on setTimeout to fire at particular wall-clock 
times, don't.  It won't.

Received on Monday, 28 February 2011 11:19:17 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:31 UTC