Chapter 8

Making and Using Objects

In This Chapter

arrow Understanding objects

arrow Using properties and methods

arrow Creating objects

arrow Using dot notation

arrow Working with objects

“We cannot do anything with an object that has no name.”

— Maurice Blanchot “Literature and the Right to Death”

In this chapter, we show you why you should use objects, how to use them, and what special powers they have to make your programs and your programming better.

ontheweb Don’t forget to visit the website to check out the online exercises relevant to this chapter!

Object of My Desire

In addition to the five primitive data types (see Chapter 3,) JavaScript also has a data type called object. JavaScript objects encapsulate data and functionality in reusable components.

To understand what objects are and how they work, it’s helpful to compare JavaScript objects with physical, real-life things. Take a guitar, for example. ...

Get Coding with JavaScript For Dummies now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.