• @SergeP, var h; and later used in: h = setInterval(...); returns a handle that you can use for clearInterval(h), because this handle - number - keeps moving... (yes it is 1 when it is the very first setInterval/setTimeout... but you do not know what other parts of the software are using setInterval/setTimeout, so your next one is something totally different.

    It is good practice to check for multiples of same setInterval, because that can really crate issues... You can prevent that by checking against that handle you get for that particular if (!h) { h = setInterval(...); }: But to be clear: the variable where you store the handle is not cleared when the interval/timeout is cleared or the timeout happens. Therefore, a good practice is to have the handle cleared like this h = clearInterval(h);respectiveh = clearTimeout(h);, and in the timeout function as first thingh = undefined;`, if it matters.

    The other thing I could think of is that some numeric / precision thing (number of significant / stored digits) and the way numbers are stored can play games with you... especially when it comes to fractions of time. Very defensive, tight and robust programming are the only way to detect that and the way out. I'm not paranoid, but somethings the absence of 'x' does not mean the presensec of '!x'... ;-)

About

Avatar for allObjects @allObjects started