6 CLASSES

Classes are a powerful programming tool for generating multiple objects with shared characteristics and behaviors. They’re a core part of object-oriented programming, a style of coding that revolves around creating objects that contain both data and functions for manipulating that data. In an object-oriented multiplayer game, for example, you might represent each player as an object of a Player class, and each enemy as an object of an Enemy class. The classes would establish what kind of data a player or enemy should have and would include functions to make the player or enemy do things, like move around or attack.

In this chapter, ...

Get JavaScript Crash Course 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.