Simple Objects

Programmers refer to things as objects. Anything that we can touch or talk about in the real world can be described as an object in the computer world. Consider movies, for instance. I think we can all agree that Star Wars is the greatest movie of all time. Right? Well, here we describe Star Wars as a JavaScript object:

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

Even though it’s short, there’s a lot going on in that example. First of all, we see that JavaScript has another use for curly braces other than just wrapping function definitions and if statements. Curly braces can also wrap JavaScript objects. Additionally, we see that JavaScript objects are just like numbers and strings—they can be assigned to a ...

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