Javascript how does it work ?

What is Javascript?

a single-threaded,
non-blocking,
synchronous,
single concurrent,
language

What is Javascript?

i have a call stack
an event loop
a callback queue
some other apis
and stuff

What does V8 have?

i have a call stack and a heap
(WTF are all those other things)

How dose it look in the browser

The call stack

one thread == one call stack == one thing at a time

Demo

The stack trace

Demo

Desktop/stacktrace.html

Blow up the stack

Demo

What happens when things are slow ?

or code that is slow;

Demo

Solution ... asynchronous callbacks :D

Demo

How does that happen

Demo

concurrency & the event loop

one thing at a time except not really

setTimeout(..,0) why ?

Demo ... more ...

defer stuff till stack is clear

Done();

return;

javascript how does it work ?

By Stefan Hagiu

javascript how does it work ?

  • 521