Skip to content
dreamcode
dreamcode
Map
JS Internals
Lesson 48 of 48
+15 XP on finish
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).
index.js
JAVASCRIPT
real JavaScript, runs in your browser
Console
Run your code to see its output here.
YOUR TURN

Give item its own active property set to false, then log item.hasOwnProperty("active") (true), item.active (false) and base.active (true).

Press Run to check your work.