Ankur Marwaha
Ankur Marwaha

Reputation: 1885

Devtools is printing some weird number in console?

Here is the code that I am running in console.

// Parameterless arrow functions that are visually easier to parse
setTimeout( () => {
  console.log('I happen sooner');
  setTimeout( () => {
    // deeper code
    console.log('I happen later');
  }, 1);
}, 1);

This logging something like this

32
I happen sooner
I happen later

I don't understand what this 32 mean, and this increments by 2 every time, I run the same code.

Upvotes: 1

Views: 49

Answers (1)

squiroid
squiroid

Reputation: 14027

It's the id of the setTimeout. It can be used in future to cancel this setTimeout.

Here are some docs

https://msdn.microsoft.com/en-us/library/ms536749(VS.85).aspx

Upvotes: 5

Related Questions