Object-Oriented JavaScript: An Introduction to Core Concepts (Page 1 of 5 )
JavaScript is a powerful object-oriented language whose capability has frequently been underestimated when compared with other OO languages. This article, the first of several parts, should help you gain a better understanding of JavaScript's true value. It will show you the basics of creating custom objects and defining their methods and properties. You will also learn some advanced concepts such as Inheritance. Plenty of real-world examples will be included.
Introduction
For the average JavaScript programmer, working with native objects exposed by this language is more than enough to meet the requirements of frequent programming tasks. Definitely, JavaScript is a powerful object-oriented language, which has suffered for a long time from a certain amount of underestimation when being compared to other full-blown object-based languages. After all, for years it’s been the best solution for performing client-side validation, working with rollovers, using pop-up windows, and other flashy stuff. Overall, there has been a misconception that JavaScript isn’t well suited for doing “serious” programming things.
True to form, JavaScript is an object-based language, but actually lacks certain features found in powerful languages such as Java or C++. However, to be fair, it offers some handy capabilities for creating custom objects. In many cases, these can be more useful than using traditional functions. This is particularly true when hiding complex functionality behind an object’s API implies a better approach to solve specific programming issues. To cite a good example, just spend a few minutes looking at the API of “GoogleMaps” objects, and probably you’ll realize what I’m talking about.
Considering that large JavaScript applications can actually have a remarkable impact in utilizing user-defined objects, as well as in encouraging code reusability, in this article I’ll show you the basics of how to create custom objects, define their methods and properties, together with some advanced concepts such as Inheritance. Of course, I won’t leave you to digest the boring theory all by itself without spicing up things with some real-world examples, so you can use them as part of your JavaScript programs.
Now that I’ve hopefully caught your curiosity about learning how to write object-oriented JavaScript, it’s time to move on and start grasping the basic concepts. Let’s get going!
Next: Working with objects in JavaScript : introducing the key concepts >>
More JavaScript Articles
More By Alejandro Gervasio