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