JavaScript Inheritance

Posted on July 22nd, 2009 by Arthur Kay

Over the past few weeks, I’ve been doing a lot of reading into how JavaScript inheritance actually works. I’ve known for some time that objects in JavaScript inherit from this magical thing called “prototype” but I never fully understood what was really happening under-the-hood.

With more than nine million Google search results for the phrase “javascript prototype inheritence” you would think that it would be easy to find an explanation that was both (1) easy to understand and (2) technically correct. In this case, you’d be wrong.

Douglas Crockford has an explanation which is technically correct but uses examples which aren’t very clear (in my opinion). Wikipedia has a nice generic explanation of prototypal inheritance, but it’s not JavaScript specific and has no technical examples.

After a good deal of searching I found a blog post by Sergio Pereira that was far and away the best article I read. While technically spot-on, Sergio’s diagrams and example code set his post apart from every other article I’ve read. I highly suggest subscribing to his RSS feed as Sergio also has a host of other great JavaScript tips.

Share and Enjoy:
  • RSS
  • Facebook
  • StumbleUpon
  • Digg
  • Sphinn
  • del.icio.us
  • Technorati
  • Reddit
  • LinkedIn
  • Twitter
  • Yahoo! Buzz

Leave a Reply