Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Notes on JavaScript prototypes

Why Objects were successful

  • essense of objects is (dynamic) dispatch
  • dispatch provides interoperability
  • first-class interoperability is critical to frameworks and ecosystems
  • frameworks and ecosystems are economically critical to the software industry
  • likely a significant factor in objects' success
  • Also talks about early mistakes in Simula

Why objects are inevitable

  • Cook's definition: "An Object is a value exporting a procedural interface to data or behavior

Self: The power of simplicity

  • real-world vs computers: can make sweeping changes by changing shared behavior in computers

Self: organizing programs without classes

Lua has prototypes via the metatable and __index property

Why prototypal inheritance matters

Prototypal OO using JS

  • rocking chair = prototype of chair + 2 rockers
    • no blueprint needed

JS the core 2nd ed

Crockford on Prototypes

  • Crockford "invents" Object.create
    • never included in the language originally
      • original JS: new f() produces a new object that inherits from f.prototype
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.