Book Image

Object-Oriented JavaScript

Book Image

Object-Oriented JavaScript

Overview of this book

Table of Contents (18 chapters)
Object-Oriented JavaScript
Credits
About the Author
About the Reviewers
Preface
Built-in Functions
Regular Expressions
Index

OOP Summary


If you are new to the OO programming lingo and you're not sure you've fully grasped the concepts above, don't worry. We'll look at some code and you'll see that, although they may seem complicated when just talking about high-level concepts, things are much simpler in practice.

Thus said, let's rehash the concepts once more.

Feature

Illustrates concept

Bob is a man (an object).

objects

Bob's date of birth is June 1st, 1980, gender: male, hair: black.

properties

Bob can eat, sleep, drink, dream, talk and calculate his age.

methods

Bob is an instance of class Programmer.

class (in classical OOP)

Bob is based on another object, called Programmer.

prototype (in prototypal OOP)

Bob holds data (such as birth date) and methods that work with the data (such as calculate age).

encapsulation

We don't need to know how the calculation method works internally. The object might have some private data, such as the number of days in February in a leap year, we don't know, nor do we want to know.

information hiding

Bob is part of a Web Dev Team object, together with Jill, a Designer object and Jack, a Project Manager object.

aggregation, composition

Designer, Project Manager and Programmer are all based on and extend a Person object.

inheritance

You can call the methods Bob:talk, Jill:talk and Jack:talk and they'll all work fine, albeit producing different results (Bob will probably talk more about performance, Jill about beauty and Jack about deadlines). Each object inherited the method talk from Person and customized it.

polymorphism, method overriding