O'Reilly logo

JavaScript® Programmer's Reference by Alexei White

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10. Object Oriented Development

In general terms, object oriented development is a programming paradigm that uses the metaphor of objects to represent both data and behavior into discrete structures. It's a style of programming adopted by plenty of modern languages such as Java, C#, C++, Ruby, Python, Perl, PHP, ColdFusion, and others. Already in this book I've broached a number of object oriented (OO) principles. Terms such as objects, classes, instances, methods, properties, and inheritance all fall under this umbrella. If you've done any JavaScript programming at all, you've probably been using these principles, so in a way, to talk about object oriented programming principals in JavaScript is a bit redundant. The very nature of the language and the Document Object Model is object oriented by design.

In this chapter I present a cross-section of OO programming principles and how they apply to JavaScript in particular. You'll also look at some common difficulties programmers have when applying these principles such as how to extend a class, create public versus private methods, or clone objects.

Object Oriented JavaScript

If you are coming from the world of Java, you might expect JavaScript to resemble somewhat what you're used to, which is a classical object oriented language. What you'll find is a completely unrelated beast. For example, very often when I talk about objects in JavaScript, I say that a particular object inherits the features of another. For example, all the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required