Chapter 10. Bracket notation: flexible property names

This chapter covers

  • Square brackets as an alternative to dot notation
  • The use of square brackets to set and get properties
  • The flexibility of square bracket notation
  • How to build a working game in The Crypt

In chapter 3 you saw how to create objects with curly braces and get and set properties with dot notation. You’ve used objects to model players, places, planets, and posts as well as quizzes and calendar events. You’ve added functions as properties to make methods and passed your objects to and from functions as arguments and return values. Objects are the center of the JavaScript universe!

In this chapter you take a look at a new way of working with object properties that gives ...

Get Get Programming with 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.