0

I want to know why the window interval timer starts from 132 or another number.

Chrome/75.0.3770.142 DevTool Console

const id = setInterval(()=>{
  console.log('hey bro');
},1000);
console.log(id);
  1. Why it doesn't start from 0?

  2. 0~131 what means in browser?

Code Maniac
  • 35,187
  • 4
  • 31
  • 54
frankkai
  • 135
  • 1
  • 2
  • 9

1 Answers1

0

setInterval() returns an identifier for you be able to stop it later using clearInterval(). Example:

const id = setInterval(()=>{
    console.log('hey bro');
},1000);

setTimeout(() => {
    clearInterval(id);
}, 5001);
guijob
  • 4,145
  • 1
  • 19
  • 35