All Objects Are Related

All built-in types — Array, Date, Function, String — use prototypal inheritance. This is where all their methods come from.

The Full Prototype Chain

[1, 2, 3]  →  Array.prototype  →  Object.prototype  →  null
              (.map, .push...)    (.toString...)
  • .push(), .map(), .filter() — live on Array.prototype.
  • .toString(), .valueOf() — live on Object.prototype, accessible to all.

Primitives and Wrappers

When you call "hello".toUpperCase(), JS temporarily wraps the string in new String("hello") to access String.prototype methods, then discards the wrapper.

Warning

The only objects without a prototype are those created via Object.create(null) — used as " pure dictionaries " with no inherited properties.