PhpRiot
Download This Article
Download this article or the entire “Eight Weeks of Prototype” series with all listings and files.




More information
Related Books
JavaScript: The Good Parts

JavaScript: The Good Parts

Most programming languages contain good and bad parts, but JavaScript has more than its share of...

Practical Prototype and script.aculo.us (Expert's Voice in Web Development)

Practical Prototype and script.aculo.us (Expert's Voice in Web Development)

As a JavaScript developer, you will already be aware of some of the time saving, convenience,...
Browse Articles
Ajax (4), APC (1), CAPTCHA (1), CSS (3), Debugging (1), File Upload (1), Google (3), Google Maps (2), JavaScript (12), JSON (2), MVC (1), MySQL (7), onbeforeunload (1), OOP (1), PHP (28), PhpDoc (1), PostgreSQL (6), Prototype (11), Reflection (1), RFC 1867 (1), Robots (1), Scriptaculous (1), SEO (1), Sessions (1), SimpleXML (1), Smarty (5), SOAP (1), SPL (1), Templates (2), W3C (1), XHTML (1), Zend Framework (1), Zend_Search_Lucene (1)

PhpRiot Newsletter
Your Email Address:

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.

In This Article


Tagged in ,