Chapter 3. Objects: grouping your data
This chapter covers
- Creating objects
- Adding properties to objects
- Accessing properties using dot notation
- Examples of objects
In chapter 2 you saw how to declare variables and assign them values, and you considered the variables you could use to model a player in The Crypt. As your programs grow, so does the number of variables you use; you need ways to organize all this data, to make your programs easier to understand and easier to update and add to in the future.
Sometimes it makes sense to group items and see them as a whole. Consider a first-aid kit; we happily treat it as a single item—“Have you packed the first-aid kit?” “Pass the first-aid kit.” ...