Eight Weeks of Prototype: Week 6, Writing JavaScript Classes with Prototype
Summary
In this article I have shown you how to create JavaScript classes using the helper functions Prototype provides. This included showing you how to create a class constructor and how to extend classes using child classes.
In addition to this, I showed you how to create a string representation of your class instances by implementing the toString() method, and how to create custom enumerable classes by extending the Enumerable class and implement a method called _each().
One of the most important concepts to take out of this article was that of function binding, which is extremely important if you are effectively going to develop JavaScript classes. I showed you how to use the bind() method for Ajax request handlers and the bindAsEventListener() method for event callbacks. Additionally, I showed you how to bind iterator functions when looping over enumerable objects.
In the next article of "Eight Weeks of Prototype", I will cover a range of miscellaneous topics that are useful for JavaScript development with Prototype.
- Download a PDF version of this article
- View or post comments for this article
- Browse similar articles by tag: JavaScript, Prototype
-
Read related articles:
- Eight Weeks of Prototype: Week 1, Beginning with Prototype
- Eight Weeks of Prototype: Week 2, How Prototype Extends Elements
- Eight Weeks of Prototype: Week 3, Prototype Data Types
- Eight Weeks of Prototype: Week 4, Event Handling in Prototype
- Eight Weeks of Prototype: Week 5, Ajax with Prototype
- Eight Weeks of Prototype: Week 7, Other Prototype Functionality
- Eight Weeks of Prototype: Week 8, A Complete Prototype Example


