Data Types
Data Types — CS 111 Review.
Pick a type above to see what it stores.
- Number. Anything you'd write as a numeric value — health, speed, position, frame count. Example:
velocity: 3. Used for physics, damage math, timers, and pretty much anything that changes over time. - String. Text in any form — names, modes, file paths, dialogue. Example:
"hostile". Used for NPC states, sprite paths, UI labels, and item or quest IDs. - Boolean. A simple yes/no switch — only ever
trueorfalse. Example:isPaused: true. Used for any binary game state:isJumping,isAlive,isAttacking, pause flags, visibility toggles. - Array. An ordered list of similar items. Example:
gameObjects[]. Used for collections — every enemy on screen, every bullet in flight, every inventory slot. - JSON Object. A bundle of named properties grouped together. Example:
{ hitbox: { width: 40 } }. Used for anything with more than one piece of info: NPC configs, level definitions, save files, dialogue trees.
Number
Numbers cover anything that ticks, counts, or measures.
velocity: 3
Physics, health, movement speed, animation timing, hit detection — if it changes frame by frame, it's a number.
String
Strings hold text — labels, modes, identifiers.
state: "hostile"
NPC behavior modes, sprite paths, dialogue, item and quest IDs all live as strings.
Boolean
The simplest type in the language. Just true or false — nothing else.
isPaused: true
Game loop control, AI flags, visibility toggles, invincibility frames, input handling — anything that has only two states.
Array
An ordered list of values, usually all of the same kind.
gameObjects[]
Every active sprite, every enemy or bullet group, particle effects, inventory slots, level layouts.
JSON Object
A bundle of related properties grouped under one name.
{ hitbox: { width: 40, height: 60 } }
NPC configs, level definitions, save files, game settings, dialogue trees.
NumberStringBooleanArrayJSON Object- Watch the "true" vs true trap — one is a string, the other is a boolean. They look identical but behave totally differently in logic checks.
- Numbers do math; strings concatenate.
"5" + 3gives"53", not8. - Arrays are best when all items are similar; objects are better when each property is different.
- A JSON object doesn't have to come from a file — it's just a way of bundling named values.