JS EXPERTChapter 9 · JS Expert
Prototypes and V8 Engine optimization
V8 compiles JS to machine code via JIT compilation. Objects inherit features through prototypes, and closures store references in heap-allocated scopes, risking leaks if not cleaned up.
Worked example
How it reads
- Object.create(proto) links a new object directly to prototype object
- Scope references are garbage collected only when closures are released

Cloud tip: Avoid changing prototypes at runtime since it destroys the engine's hidden class optimizations (inline caches).


