Introduction

Most developers associate object-oriented programming with languages that are typically taught in school, like C++ and Java, which base object-oriented programming around classes. Before you can do anything in these languages, you need to create a class, even if you’re just writing a simple command-line program.

Common design patterns in the industry reinforce class-based concepts as well. But JavaScript doesn’t use classes, and this is part of the reason people get confused when they try learning it after C++ or Java.

Object-oriented languages have several characteristics:

Encapsulation. Data can be grouped together with functionality that operates on that data. This, quite simply, is the definition of an object.

Aggregation. One object ...

Get The Principles of Object-Oriented JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.