require('something');
// 1. try something.js
// 2. try something.json
// 3. try something.node
Event Model
Handling Slow I/O
The entity that handles external events and converts them into callback invocations
A loop that picks events from the event queue and pushes their callbacks to the call stack
anonymous()
printDouble(9)
double(9)
add(9, 9)
anonymous()
printDouble(9)
console.log(18)
add(9, 9)
double(9)
anonymous()
slowAdd(3, 3)
slowAdd(4, 4)
slowAdd(5, 5)
console.log(6)
console.log(8)
console.log(10)
anonymous()
slowAdd(3, 3)
setTimeout()
slowAdd(4, 4)
setTimeout()
console.log(6)
console.log(8)
Timer()
cb1
cb2
cb1
cb2
anonymous()
slowAdd(3, 3)
setTimeout(cb1, d)
Timer
cb1
slowAdd(4, 4)
setTimeout(cb2, d)
Timer
cb2
cb1
cb2
cb1
console.log(6)
cb2
console.log(8)
anonymous()
slowAdd(3, 3)
setTimeout(cb1, d)
Timer
cb1
cb1
slowAdd(4, 4)
setTimeout(cb2, d)
Timer
cb2
cb2
cb1
console.log(6)
console.log(6)
cb2