Engrain by ByteRush

JS.12.02 Senior

Hidden classes (shapes) and inline caches

Comes up in: JavaScript, Web fundamentals

This concept is being written. It gets the full five steps — explanation, predict, interview angle, practice with tests, and review cards. Here is exactly what it will cover, so you can study it elsewhere in the meantime.

What it covers

  • shapes/maps
  • adding properties in a consistent order
  • monomorphic vs polymorphic vs megamorphic call sites
  • delete and dictionary mode
  • element kinds for arrays (holey/packed)

Words you will know

hidden classinline cachemonomorphicmegamorphic

What you will practise

  • micro-benchmark caveats + a shape-friendly refactor

Interview questions this answers

  • What are hidden classes and why should objects keep a consistent shape?