I am writing a check to see if a timeout is active. I was thinking of doing this:
var a = setTimeout(fn, 10);
// ... Other code ... where clearTimeout(a) can
The specifications from Microsoft, Sun and Mozilla just say that it will return an integer. So 0
may be included.
It may be possible (and probable) that some implementations exclude 0
but you shouldn't rely on that. You should go with the !==
.
To summarize: Although probably all browser exclude 0
from the IDs returned by setTimeout
, you should not write your code with that in mind especially when all your have to do is add an extra =
.