0

I know JavaScript is single threaded non blocking, and hands things such as setTimeout() to the web api, but how does it handle scopes?

lets say there is a function like

function example()
{
  const x = 10
  setTimeout(() => { console.log(x) }), 100)
}

example()

How does it keep track of the variables in that scope? or do they not get deleted?

PumpkinQL
  • 63
  • 1
  • 6
  • 1
    Are you asking how closures are implemented internally in v8? If so, I don't think this is the place to get an answer. – connexo Feb 05 '22 at 21:03
  • V8 doesn't handle closures any different whether a web API is used or not. – Bergi Feb 05 '22 at 21:19

0 Answers0