Opera takes the cake

In Firefox, Chrome, and Safari, timeouts passed to setTimeout are subject to signed 32-bit integer arithmetic overflow. For instance, the following code shows an alert immediately, as if zero or a negative value had been supplied.

setTimeout(function() { alert('hi') }, 2147483648);

Internet Explorer has the same problem, except they use unsigned 32-bit integers. Try this one in IE:

setTimeout(function() { alert('hi') }, 4294967296);

Opera gets it right! At least I can’t get an alert to show up using any values near 231, 232, 263, and 264. I suspect (but am not patient enough to confirm) that they clamp the value. Kudos to an anonymous Norwegian programmer.

P.S. How on earth could this ever matter? 2147483648 ms is just under 25 days. This falls into the ballpark of long session lengths.