19: Data Objects

JavaScript contains the interesting design decision to confuse the word "object" with two different uses. In one way an "object" is a container for data that is key=value style. You might find this form of data in a database table, a spreadsheet, or even if you look at your Contacts on your phone. The other use for "object" is in "object-oriented programming (OOP)", which is a much more complicated topic that we'll cover later in the book. In OOP you are using a combination of objects, classes, and functions to constrain your programming style so that your code can work better with other people's code.

In this exercise we'll focus on objects as a data type (or container), and I'll call them "data objects" to differentiate them from "objects" in object-oriented programming. There really is no difference between a "data object" and an "OOP object". They are the exact same thing but used in different ways. Using an object to store key=value data is the first simplest usage of an object. Then when you learn OOP you'll learn how to add to the "data object" concept for object-oriented programming.

Key/Value Structures

You use key=value data all the time without realizing it. When you read an email you might have:

Learn JavaScript Today

Register today for the Beginner Basics course and get the new releases by just paying the difference. There's also special discounts for existing customers when new courses are released.

Still Not Sure? Check out more curriculum!