Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

120
Vistas
Interval id counter keeps growing after clearing old one

Suppose I have the following intervals, the id of the first interval is 1, even that I cleared it the second interval gets id of 2. is there a way the I can reset the interval's id when it cleared? such that the second interval will have id of 1.

let it=setInterval(function(){
console.log(it);// prints 1
},1000);

clearInterval(1);

let it2=setInterval(function(){
console.log(it2); // prints 2
},1000);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

...is there a way the I can reset the interval's id when it cleared?

No. Every time you call setInterval or setTimeout, a new handle value is created. This is per specification. The only thing you can rely on about the handle is that, in the browser environment, it will be a whole number greater than 0 and won't be the same as any other timer handle that's been provided by previous calls in the same realm (roughly, on that page). (On Node.js it's not a number, it's an object.) (The fact it's never 0 is handy; you can use 0 as a "no timer is set" value for the handle variable.)

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda