Chapter 7

Making and Using Objects

IN THIS CHAPTER

Bullet Creating, modifying, comparing, and copying objects

Bullet Introducing prototypes

Bullet Deleting object properties

“You can find the entire cosmos lurking in its least remarkable objects.”

—WISLAWA SZYMBORSKA

Data is rarely as simple as it seems. To understand any concept or physical object often requires multiple data points. A full description of a toaster, for example, would include its size, color, and power requirements as well as a description of what it does. None of the data types I describe earlier in this book can be used to describe a toaster by themselves, but in combination, they can.

Objects: The Basics

Objects are reusable components that contain data and functionality. Objects in real life have characteristics that define what they are. For example, a pencil has a length, a diameter, a color, and other characteristics that describe it. A pencil also has things you can do with it, such as write, erase, sharpen, and break.

In JavaScript, both the data and functionality encapsulated by an object are called properties. If a property has a function value, it's also known as a method. JavaScript objects can be used to describe physical ...

Get JavaScript All-in-One For Dummies 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.