Quantcast
Channel: How is Javascript single threaded? - Stack Overflow
Viewing all articles
Browse latest Browse all 7

Answer by Brian McGinity for How is Javascript single threaded?

$
0
0

Javascript executes each line in sequence.

So you told js:

  • write 1: js writes 1
  • wait 3 seconds and then write 2: ok I'll wait 3 seconds...now what?
  • write 3: ok I'll write 3, by the way, the 3 seconds is not up.
  • wait 1 second and then write 4: ok I'll wait 1 second...

then js waits .99999 seconds ... and writes 4

then waits some more and writes 2


Viewing all articles
Browse latest Browse all 7

Trending Articles