LAB-03OPERATIONAL
JavaScript Lab
Department of Runtime Phenomena
Electrical equipment, glowing circuits and a very long queue. We study what the language promises, what the engine actually does, and the gap in between where all the interesting bugs live.
SINGLE THREAD. DO NOT BLOCK
event loopmicrotasksclosurescoercionprototypesmemorygarbage collection
LAB-03
Experiments
- javascriptENGINEER
Event loop investigation
One call stack, two queues and a rule about when the browser is allowed to breathe.
javascript12 min - javascriptDEVELOPER
Promise vs setTimeout
Predict the output first. Then watch the queues prove you right, or, more usefully, wrong.
javascript6 min - javascriptRESEARCHER
Closure memory investigation
A one-line callback keeps a 40MB array alive for the lifetime of the page. Find out which line did it.
javascript10 min - javascriptDEVELOPER
JavaScript coercion experiment
`[] + []` is an empty string. `[] + {}` is an object tag. `{} + []` is zero, but only in a console. All of it follows one algorithm.
javascript7 min