Chapter 8. All About Objects
This chapter covers
- Declaring JavaScript objects
- Defining reusable object types
- Writing object-oriented JavaScript using Prototype
In part 2, we looked at how we can use Prototype and Scriptaculous to achieve a number of quick wins for our application development. Using the libraries in this way requires relatively little understanding of the internal functioning of the libraries themselves. Indeed, it requires little understanding of the language features that the libraries make use of. That’s one of the strengths of these libraries—for the casual user, the learning curve is not at all steep, and the payback is considerable. You may not need to take your use of the libraries beyond this level, in which case you’ve already got a very good return on your investment.
On the other hand, the libraries also provide a great deal of power and elegance for the more advanced user. Much of the advanced, low-level capability is provided by Prototype.js, and in the next few chapters, we will explore these capabilities more thoroughly. In part 4, we will take a second look at Scriptaculous, in light of what we have learned. That extra knowledge will make it easier to understand how Scriptaculous does what it does, but it will also help you to extend the Scriptaculous code base yourself.
Prototype provides a lot of its power by extending the core JavaScript classes. We’ll begin our tour of these by looking at the most fundamental of all classes, the Object.