Describing a Thing in JavaScript

Have you noticed how we introduce new things in JavaScript?

 
// You don't need to type this in:
 
var​ head_shape = ​new​ THREE.SphereGeometry(100);

The var keyword declares new things in JavaScript. It tells both the computer and humans reading the code, “Get ready—something new is coming!”

There are lots of different kinds of things in JavaScript. In the little bit of code you just saw, we’re making a new 3D sphere shape. Things can also be numbers:

 
var​ my_height = 1.5;

They can be words:

 
var​ title = ​"3D Game Programming for Kids"​;

Programmers usually call the things inside quotation marks strings. Here the title item is a string that holds the title of this book.

Strings Are Easy to Break

Always ...

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.