Chapter 7. Objects and Built-In Types

You live in an object-based world. Stop and think about the objects you come in contact with pretty much every second of every day. Whether you're driving to work or school, sitting at a table eating dinner, sleeping in a bed, or even walking in a field — you're interacting with objects. You don't even think about most of the objects you come in contact with every day. Interaction with objects is natural to you.

Before the 1990s, programmers primarily used procedural programming languages. These languages were based on the steps a program takes to reach the desired goal — very much like the examples thus far in this book. It wasn't until the 1990s that mainstream developers began to shift their thinking to involve objects.

Objects are a very important part of JavaScript: In fact, just about everything in JavaScript is an object. An understanding of what objects are and how to use them is required in order to use the language to its full potential. First let's talk a little more about what objects are and why they're useful.

WHAT ARE OBJECTS?

It's easiest to understand objects in a programming context by comparing them with real-world examples. Consider an automobile as an example. Automobiles come in a variety of colors, and are made by manufacturers that build them into different models. Some have vinyl interiors, while others have leather. Most automobiles come with an automatic transmission, and a small number of them have manual transmissions. ...

Get JavaScript® 24-Hour Trainer 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.