Category: JavaScript

  • JavaScript subclassing using Object.create

    In my previous post, I talked about how Microsoft’s TypeScript was able to build simple class-based inheritance on top of JavaScript’s prototypal inheritance. To recap, the compiler includes a short function named extends that handles rejigging the prototype chain between the sub-class and the super-class to achieve the desired inheritance. [javascript] var __extends = this.__extends […]

  • Exploring JavaScript prototypes via TypeScript’s class pattern

    Note: All the diagrams below were created using Gliffy, a fantastic web-based diagram editor. The latest version has been rebuilt using HTML and JS instead of Flash, and it really is a joy to use. In this post, I’m going to take a close look at how JavaScript’s prototypal inheritance works by analysing how Microsoft’s TypeScript language uses […]