Suppose I have an array that stores all my ids used for setInterval.
What if I want to create an id, dynamically... can I do like this?
id_array.push(++id_var) = setInterval(function, milliseconds);
See?
I also have a variable, called 'id_var', that I believe, if I increment it, it will give me, a new 'id'.
Is this code correct?
The return value from setInterval() is an opaque token. You just store it somewhere until you want to remove the interval timer with clearInterval().
You cannot control the value of what you receive, nor can you do any kind of arithmetic on it. Just store it and retrieve it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With