Simple Objects

Anything that we can touch or talk about in the real or virtual world can be described in computer programming: an avatar, a car, a tree, a book, a movie. Anything. When programmers talk about things in the computer world, we call these things objects. Let’s think about movies. I think we can all agree that Star Wars is the greatest movie of all time, right? Of course we can.

Well, let’s describe Star Wars as a JavaScript object. Add the following below “Your code goes here…”:

​ ​var​ bestMovie = {
​  title: ​'Star Wars'​,
​  year: 1977,
​ };

Hey, wait. Isn’t that just a map, which we first met all the way back in Chapter 7, ​A Closer Look at JavaScript Fundamentals​? The answer is, Yes! But it ...

Get 3D Game Programming for Kids, 2nd Edition 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.