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.