Object-Oriented JavaScript: Building Real-World Examples
(Page 1 of 4 )
In the first two parts of this series, we've explored the most important points related to object-oriented JavaScript. In this final part, we go through the development of some practical examples for creating helpful objects that can be used in different JavaScript applications.
Introduction
Welcome to the last installment of the series “Object-oriented JavaScript.” In three parts, this series introduces the core concepts for working with user-defined object in JavaScript, and shows how to use them, particularly in large applications, where a bunch of reusable objects can very often yield better results than using conventional JavaScript functions.
In order to refresh the concepts deployed during the previous articles, let’s reflect briefly on some of the most important points regarding the usage of user-defined objects in the JavaScript terrain. For obvious reasons, the first tutorial went through the key points for defining constructor functions and object instantiation, as well as for declaring properties and methods. Also, a few additional object-based features were conveniently illustrated, by taking a brief look at the “constructor” property and “Functions” objects, and their appropriate implementation through hands-on examples.
Going one step further in the learning curve, in the second tutorial I explained the use of the “prototype” property, which, as you may have realized, is extremely helpful for applying inheritance between objects. It allows the definition of base constructor functions, followed by the derivation of as many objects as required from the corresponding functions. In fact, the most remarkable aspect of using the “prototype” property is the ability to encapsulate as much functionality as possible in base (or parent) objects, and then create child objects that eventually will override or annex properties and methods inherited from the base constructor functions. Pretty nice, right? If you were thinking that only full-fledged programming languages were capable of offering inheritance capabilities, this is really good news.
Having walked a long way through the nitty-gritty of user-created objects in JavaScript, the question is: what’s next? Well, in this final tutorial I’ll develop some real-world examples that obviously will include custom objects, so you can have a pretty clear idea of how to implement them in modern Web applications. The journey will begin building in pop-up window constructors, as well as http requester objects, and end up developing form validating objects, which you can easily introduce in your scripts. Sounds good enough to you? All right, let’s get started.
Next: The first hands-on example: building object-based pop-up windows >>
More JavaScript Articles
More By Alejandro Gervasio